How to use the @graphql-codegen/plugin-helpers.turnExtensionsIntoObjectTypes function in @graphql-codegen/plugin-helpers

To help you get started, we’ve selected a few @graphql-codegen/plugin-helpers 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 / graphql-codegen-core / src / codegen.ts View on Github external
if (!addToSchema) {
      return schema;
    }

    schemaChanged = true;

    return mergeSchemas([schema, addToSchema]);
  }, options.schema);

  const federationInConfig = pickFlag('federation', options.config);
  const isFederation = prioritize(federationInConfig, false);

  if (isFederation) {
    schemaChanged = true;
    schema = turnExtensionsIntoObjectTypes(mergeSchemas([schema, federationSpec]));
  }

  if (schemaChanged) {
    options.schemaAst = buildASTSchema(schema, {
      assumeValidSDL: isFederation,
    });
  }

  const skipDocumentValidation = typeof options.config === 'object' && !Array.isArray(options.config) && options.config.skipDocumentsValidation;

  if (options.schemaAst && documents.length > 0 && !skipDocumentValidation) {
    const extraFragments = options.config && (options.config as any)['externalFragments'] ? (options.config as any)['externalFragments'] : [];
    const errors = await validateGraphQlDocuments(options.schemaAst, [
      ...documents.map(({ filePath, content }) => ({ location: filePath, document: content })),
      ...extraFragments.map((f: any) => ({ location: f.importFrom, document: { kind: Kind.DOCUMENT, definitions: [f.node] } })),
    ]);