How to use the @graphql-codegen/visitor-plugin-common.buildScalars function in @graphql-codegen/visitor-plugin-common

To help you get started, we’ve selected a few @graphql-codegen/visitor-plugin-common 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 dotansimha / graphql-code-generator / packages / plugins / java / kotlin / src / visitor.ts View on Github external
constructor(rawConfig: KotlinResolversPluginRawConfig, private _schema: GraphQLSchema, defaultPackageName: string) {
    super(rawConfig, {
      enumValues: rawConfig.enumValues || {},
      listType: rawConfig.listType || 'Iterable',
      package: rawConfig.package || defaultPackageName,
      scalars: buildScalars(_schema, rawConfig.scalars, KOTLIN_SCALARS),
    });
  }
github dotansimha / graphql-code-generator / packages / plugins / typescript / compatibility / src / visitor.ts View on Github external
constructor(rawConfig: CompatabilityPluginRawConfig, private _schema: GraphQLSchema, options: { reactApollo: any }) {
    super(rawConfig, {
      reactApollo: options.reactApollo,
      noNamespaces: getConfigValue(rawConfig.noNamespaces, false),
      preResolveTypes: getConfigValue(rawConfig.preResolveTypes, false),
      strict: getConfigValue(rawConfig.strict, false),
      scalars: buildScalars(_schema, rawConfig.scalars),
    } as any);
  }
github dotansimha / graphql-code-generator / packages / plugins / typescript / mongodb / src / visitor.ts View on Github external
constructor(private _schema: GraphQLSchema, pluginConfig: TypeScriptMongoPluginConfig) {
    super(pluginConfig, ({
      dbTypeSuffix: pluginConfig.dbTypeSuffix || 'DbObject',
      dbInterfaceSuffix: pluginConfig.dbInterfaceSuffix || 'DbInterface',
      objectIdType: resolveObjectId(pluginConfig.objectIdType).identifier,
      objectIdImport: resolveObjectId(pluginConfig.objectIdType).module,
      idFieldName: pluginConfig.idFieldName || '_id',
      enumsAsString: getConfigValue(pluginConfig.enumsAsString, true),
      avoidOptionals: getConfigValue(pluginConfig.avoidOptionals, false),
      scalars: buildScalars(_schema, pluginConfig.scalars, DEFAULT_SCALARS),
    } as Partial) as any);
    autoBind(this);
    this._variablesTransformer = new TypeScriptOperationVariablesToObject(this.scalars, this.convertName, false, false);
  }
github dotansimha / graphql-code-generator / packages / plugins / java / java / src / visitor.ts View on Github external
constructor(rawConfig: JavaResolversPluginRawConfig, private _schema: GraphQLSchema, defaultPackageName: string) {
    super(rawConfig, {
      enumValues: rawConfig.enumValues || {},
      listType: rawConfig.listType || 'Iterable',
      className: rawConfig.className || 'Types',
      package: rawConfig.package || defaultPackageName,
      scalars: buildScalars(_schema, rawConfig.scalars, JAVA_SCALARS),
    });
  }
github aws-amplify / amplify-cli / packages / amplify-codegen-appsync-model-plugin / src / visitors / appsync-visitor.ts View on Github external
constructor(
    protected _schema: GraphQLSchema,
    rawConfig: TRawConfig,
    additionalConfig: Partial,
    defaultScalars: NormalizedScalarsMap = DEFAULT_SCALARS
  ) {
    super(rawConfig, {
      ...additionalConfig,
      scalars: buildScalars(_schema, rawConfig.scalars || '', defaultScalars),
    });

    const typesUsedInDirectives: string[] = [];
    if (rawConfig.directives) {
      const directiveSchema = parse(rawConfig.directives);
      directiveSchema.definitions.forEach((definition: DefinitionNode) => {
        if (definition.kind === Kind.ENUM_TYPE_DEFINITION || definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION) {
          typesUsedInDirectives.push(definition.name.value);
        }
      });
    }

    this.typesToSkip = [this._schema.getQueryType(), this._schema.getMutationType(), this._schema.getSubscriptionType()]
      .filter(t => t)
      .map(t => (t && t.name) || '');
    this.typesToSkip.push(...typesUsedInDirectives);
github dotansimha / graphql-code-generator / packages / presets / near-operation-file / src / index.ts View on Github external
buildGeneratesSection: options => {
    const schemaObject: GraphQLSchema = options.schemaAst ? options.schemaAst : buildASTSchema(options.schema);
    const baseVisitor = new BaseVisitor(options.config, {
      scalars: buildScalars(schemaObject, options.config.scalars),
    });

    const getAllFragmentSubTypes = (possbileTypes: string[], name: string, suffix: string): string[] => {
      if (possbileTypes.length === 0) {
        return [];
      } else if (possbileTypes.length === 1) {
        return [
          baseVisitor.convertName(name, {
            useTypesPrefix: true,
            suffix: suffix,
          }),
        ];
      } else {
        return possbileTypes.map(typeName =>
          baseVisitor.convertName(name, {
            useTypesPrefix: true,
github dotansimha / graphql-code-generator / packages / plugins / java / resolvers / src / visitor.ts View on Github external
constructor(rawConfig: JavaResolversPluginRawConfig, private _schema: GraphQLSchema, defaultPackageName: string) {
    super(rawConfig, {
      mappers: transformMappers(rawConfig.mappers || {}),
      package: rawConfig.package || defaultPackageName,
      defaultMapper: parseMapper(rawConfig.defaultMapper || 'Object'),
      className: rawConfig.className || 'Resolvers',
      listType: rawConfig.listType || 'Iterable',
      scalars: buildScalars(_schema, rawConfig.scalars, JAVA_SCALARS),
    });
  }