How to use the babel-core/lib/types.identifier function in babel-core

To help you get started, we’ve selected a few babel-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
return str.split('.').reduce((acc, name) => {
    if (!acc) {
      return t.identifier(name);
    }
    return t.memberExpression(acc, t.identifier(name));
  }, null);
}
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
function property(name: string, value: mixed): Printable {
  return t.property('init', t.identifier(name), value);
}
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
rootField.getDeclaredArgument('input')
      ),
    };

    return t.newExpression(
      t.memberExpression(
        t.identifier('GraphQL'),
        t.identifier('Mutation')
      ),
      trimArguments([
        t.literal(mutation.getName()),
        t.literal(rootFieldType.getName({modifiers: true})),
        t.newExpression(
          t.memberExpression(
            t.identifier('GraphQL'),
            t.identifier('Callv')
          ),
          trimArguments([
            t.literal(rootField.getName()),
            this.printVariable('input')
          ])
        ),
        selection.fields,
        selection.fragments,
        objectify(metadata)
      ])
    );
  }
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
printFragmentReference(fragmentReference: RelayQLFragmentSpread): Printable {
    return t.callExpression(
      t.memberExpression(
        identify(this.tagName),
        t.identifier('__frag')
      ),
      [t.identifier(fragmentReference.getName())]
    );
  }
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
}
    if (generatedSiblings.hasOwnProperty(field.getName())) {
      metadata.generated = true;
    }
    if (requisiteSiblings.hasOwnProperty(field.getName())) {
      metadata.requisite = true;
    }

    const selection = this.printSelection(field, requisiteFields);
    const fieldAlias = field.getAlias();
    const args = field.getArguments();

    return t.newExpression(
      t.memberExpression(
        t.identifier('GraphQL'),
        t.identifier('Field')
      ),
      trimArguments([
        t.literal(field.getName()),
        selection.fields,
        selection.fragments,
        args.length ?
          t.arrayExpression(args.map(arg => this.printArgument(arg))) :
          NULL,
        fieldAlias ?
          t.literal(fieldAlias) :
          NULL,
        NULL,
        objectify(metadata),
        this.printDirectives(field.getDirectives())
      ])
    );
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
        substitutions.map(substitution => t.identifier(substitution.name)),
        t.blockStatement([
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
printValue(value: mixed): Printable {
    if (Array.isArray(value)) {
      return t.arrayExpression(
        value.map(element => this.printArgumentValue(element))
      );
    }
    return t.newExpression(
      t.memberExpression(
        t.identifier('GraphQL'),
        t.identifier('CallValue')
      ),
      [t.literal(value)]
    );
  }
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
printFragmentReference(fragmentReference: RelayQLFragmentSpread): Printable {
    return t.callExpression(
      t.memberExpression(
        identify(this.tagName),
        t.identifier('__frag')
      ),
      [t.identifier(fragmentReference.getName())]
    );
  }
github facebook / relay / scripts / babel-relay-plugin / src / RelayQLPrinter.js View on Github external
} else {
      invariant(false, 'Unsupported definition: %s', definition);
    }
    const callExpression = t.callExpression(
      t.functionExpression(
        null,
        substitutions.map(substitution => t.identifier(substitution.name)),
        t.blockStatement([
          t.variableDeclaration(
            'var',
            [
              t.variableDeclarator(
                t.identifier('GraphQL'),
                t.memberExpression(
                  identify(this.tagName),
                  t.identifier('__GraphQL')
                )
              )
            ]
          ),
          t.returnStatement(printedDocument),
        ])
      ),
      substitutions.map(substitution => substitution.value)
    );

    if (this.tagName === 'Relay.Query') {
      return t.callExpression(
        identify('Relay.createQuery'),
        [
          callExpression,
          t.objectExpression([])