graphql#buildASTSchema TypeScript Examples

The following examples show how to use graphql#buildASTSchema. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: schema.ts    From squid with GNU General Public License v3.0 6 votes vote down vote up
baseSchema = buildASTSchema(parse(`
    directive @entity on OBJECT
    directive @derivedFrom(field: String!) on FIELD_DEFINITION
    directive @unique on FIELD_DEFINITION
    directive @index(fields: [String!] unique: Boolean) on OBJECT | FIELD_DEFINITION
    directive @fulltext(query: String!) on FIELD_DEFINITION
    directive @variant on OBJECT # legacy
    directive @jsonField on OBJECT # legacy
    scalar ID
    ${Object.keys(customScalars).map(name => 'scalar ' + name).join('\n')}
`))
Example #2
Source File: index.ts    From graphql-mesh with MIT License 5 votes vote down vote up
async getNonExecutableSchemaForHTTPSource(
    httpSourceConfig: YamlConfig.GraphQLHandlerHTTPConfiguration
  ): Promise<GraphQLSchema> {
    const schemaHeadersFactory = getInterpolatedHeadersFactory(httpSourceConfig.schemaHeaders || {});
    const customFetch = await this.getCustomFetchImpl(httpSourceConfig.customFetch);
    if (httpSourceConfig.introspection) {
      const headers = schemaHeadersFactory({
        env: process.env,
      });
      const sdlOrIntrospection = await readFileOrUrl<string | IntrospectionQuery | DocumentNode>(
        httpSourceConfig.introspection,
        {
          cwd: this.baseDir,
          allowUnknownExtensions: true,
          fetch: customFetch,
          headers,
        }
      );
      if (typeof sdlOrIntrospection === 'string') {
        return buildSchema(sdlOrIntrospection);
      } else if (isDocumentNode(sdlOrIntrospection)) {
        return buildASTSchema(sdlOrIntrospection);
      } else if (sdlOrIntrospection.__schema) {
        return buildClientSchema(sdlOrIntrospection);
      }
      throw new Error(`Invalid introspection data: ${util.inspect(sdlOrIntrospection)}`);
    }
    return this.nonExecutableSchema.getWithSet(() => {
      const endpointFactory = getInterpolatedStringFactory(httpSourceConfig.endpoint);
      const executor = this.urlLoader.getExecutorAsync(httpSourceConfig.endpoint, {
        ...httpSourceConfig,
        customFetch,
        subscriptionsProtocol: httpSourceConfig.subscriptionsProtocol as SubscriptionProtocol,
      });
      return introspectSchema(function meshIntrospectionExecutor(params: ExecutionRequest) {
        const resolverData = getResolverData(params);
        return executor({
          ...params,
          extensions: {
            ...params.extensions,
            headers: schemaHeadersFactory(resolverData),
            endpoint: endpointFactory(resolverData),
          },
        });
      });
    });
  }
Example #3
Source File: index.ts    From graphql-mesh with MIT License 5 votes vote down vote up
async getCodeFirstSource({
    schema: schemaConfig,
  }: YamlConfig.GraphQLHandlerCodeFirstConfiguration): Promise<MeshSource> {
    if (schemaConfig.endsWith('.graphql')) {
      const rawSDL = await readFileOrUrl<string>(schemaConfig, {
        cwd: this.baseDir,
        allowUnknownExtensions: true,
        importFn: this.importFn,
      });
      const schema = buildSchema(rawSDL);
      return {
        schema,
      };
    } else {
      // Loaders logic should be here somehow
      const schemaOrStringOrDocumentNode = await loadFromModuleExportExpression<GraphQLSchema | string | DocumentNode>(
        schemaConfig,
        { cwd: this.baseDir, defaultExportName: 'schema', importFn: this.importFn }
      );
      let schema: GraphQLSchema;
      if (schemaOrStringOrDocumentNode instanceof GraphQLSchema) {
        schema = schemaOrStringOrDocumentNode;
      } else if (typeof schemaOrStringOrDocumentNode === 'string') {
        schema = buildSchema(schemaOrStringOrDocumentNode);
      } else if (
        typeof schemaOrStringOrDocumentNode === 'object' &&
        schemaOrStringOrDocumentNode?.kind === Kind.DOCUMENT
      ) {
        schema = buildASTSchema(schemaOrStringOrDocumentNode);
      } else {
        throw new Error(
          `Provided file '${schemaConfig} exports an unknown type: ${util.inspect(
            schemaOrStringOrDocumentNode
          )}': expected GraphQLSchema, SDL or DocumentNode.`
        );
      }
      return {
        schema,
      };
    }
  }
Example #4
Source File: index.ts    From graphql-mesh with MIT License 5 votes vote down vote up
PredefinedProxyOptions: Record<PredefinedProxyOptionsName, ProxyOptions<any>> = {
  JsonWithoutValidation: {
    codify: v => `export default ${JSON.stringify(v, null, 2)}`,
    fromJSON: v => v,
    toJSON: v => v,
    validate: () => null,
  },
  StringWithoutValidation: {
    codify: v => `export default ${JSON.stringify(v, null, 2)}`,
    fromJSON: v => v,
    toJSON: v => v,
    validate: () => null,
  },
  GraphQLSchemaWithDiffing: {
    codify: schema =>
      `
import { buildASTSchema } from 'graphql';

const schemaAST = ${JSON.stringify(getDocumentNodeFromSchema(schema), null, 2)};

export default buildASTSchema(schemaAST, {
  assumeValid: true,
  assumeValidSDL: true
});
    `.trim(),
    fromJSON: schemaAST => buildASTSchema(schemaAST, { assumeValid: true, assumeValidSDL: true }),
    toJSON: schema => getDocumentNodeFromSchema(schema),
    validate: async (oldSchema, newSchema) => {
      const changes = await diff(oldSchema, newSchema);
      const errors: string[] = [];
      for (const change of changes) {
        if (
          change.criticality.level === CriticalityLevel.Breaking ||
          change.criticality.level === CriticalityLevel.Dangerous
        ) {
          errors.push(change.message);
        }
      }
      if (errors.length) {
        throw new AggregateError(errors);
      }
    },
  },
}
Example #5
Source File: loading.ts    From amplify-codegen with Apache License 2.0 5 votes vote down vote up
function loadSDLSchema(schemaPath: string): GraphQLSchema {
  const authDirectivePath = normalize(join(__dirname, '../../..', 'awsAppSyncDirectives.graphql'));
  const doc = loadAndMergeQueryDocuments([authDirectivePath, schemaPath]);
  return buildASTSchema(doc);
}
Example #6
Source File: loading.ts    From amplify-codegen with Apache License 2.0 5 votes vote down vote up
function loadSDLSchema(schemaPath: string): GraphQLSchema {
  const authDirectivePath = normalize(join(__dirname, '..', 'awsAppSyncDirectives.graphql'));
  const doc = loadAndMergeQueryDocuments([authDirectivePath, schemaPath]);
  return buildASTSchema(doc);
}
Example #7
Source File: handler.spec.ts    From graphql-mesh with MIT License 4 votes vote down vote up
describe('graphql', () => {
  it('handle SDL files correctly as endpoint', async () => {
    const sdlFilePath = './fixtures/schema.graphql';
    const store = new MeshStore('.mesh', new InMemoryStoreStorageAdapter(), {
      readonly: false,
      validate: false,
    });
    const handler = new GraphQLHandler({
      name: 'SDLSchema',
      config: {
        schema: sdlFilePath,
      },
      baseDir: __dirname,
      cache: new InMemoryLRUCache(),
      pubsub: new PubSub(),
      store,
      importFn: defaultImportFn,
      logger,
    });
    const absoluteFilePath = join(__dirname, sdlFilePath);
    const schemaStringFromFile = await readFile(absoluteFilePath, 'utf-8');
    const schemaFromFile = buildSchema(schemaStringFromFile);
    const { schema: schemaFromHandler } = await handler.getMeshSource();
    expect(introspectionFromSchema(schemaFromHandler)).toStrictEqual(introspectionFromSchema(schemaFromFile));
  });
  it('handle code files exports GraphQLSchema correctly', async () => {
    const schemaFilePath = './fixtures/schema.js';
    const store = new MeshStore('.mesh', new InMemoryStoreStorageAdapter(), {
      readonly: false,
      validate: false,
    });
    const handler = new GraphQLHandler({
      name: 'SDLSchema',
      config: {
        schema: schemaFilePath,
      },
      baseDir: __dirname,
      cache: new InMemoryLRUCache(),
      pubsub: new PubSub(),
      store,
      importFn: defaultImportFn,
      logger,
    });
    const absoluteFilePath = join(__dirname, schemaFilePath);
    const schemaFromFile = require(absoluteFilePath);
    const { schema: schemaFromHandler } = await handler.getMeshSource();
    expect(introspectionFromSchema(schemaFromHandler)).toStrictEqual(introspectionFromSchema(schemaFromFile));
  });
  it('handle code files exports DocumentNode correctly', async () => {
    const schemaFilePath = './fixtures/schema-document.js';
    const store = new MeshStore('.mesh', new InMemoryStoreStorageAdapter(), {
      readonly: false,
      validate: false,
    });
    const handler = new GraphQLHandler({
      name: 'SDLSchema',
      config: {
        schema: schemaFilePath,
      },
      baseDir: __dirname,
      cache: new InMemoryLRUCache(),
      pubsub: new PubSub(),
      store,
      importFn: defaultImportFn,
      logger,
    });
    const absoluteFilePath = join(__dirname, schemaFilePath);
    const schemaDocumentFromFile = require(absoluteFilePath);
    const schemaFromFile = buildASTSchema(schemaDocumentFromFile);
    const { schema: schemaFromHandler } = await handler.getMeshSource();
    expect(introspectionFromSchema(schemaFromHandler)).toStrictEqual(introspectionFromSchema(schemaFromFile));
  });
  it('handle code files exports string correctly', async () => {
    const schemaFilePath = './fixtures/schema-str.js';
    const store = new MeshStore('.mesh', new InMemoryStoreStorageAdapter(), {
      readonly: false,
      validate: false,
    });
    const handler = new GraphQLHandler({
      name: 'SDLSchema',
      config: {
        schema: schemaFilePath,
      },
      baseDir: __dirname,
      cache: new InMemoryLRUCache(),
      pubsub: new PubSub(),
      store,
      importFn: defaultImportFn,
      logger,
    });
    const absoluteFilePath = join(__dirname, schemaFilePath);
    const schemaStringFromFile = require(absoluteFilePath);
    const schemaFromFile = buildSchema(schemaStringFromFile);
    const { schema: schemaFromHandler } = await handler.getMeshSource();
    expect(introspectionFromSchema(schemaFromHandler)).toStrictEqual(introspectionFromSchema(schemaFromFile));
  });
});
Example #8
Source File: generated.ts    From tql with MIT License 4 votes vote down vote up
SCHEMA = buildASTSchema({
  kind: Kind.DOCUMENT,
  definitions: [
    {
      kind: Kind.SCHEMA_DEFINITION,
      directives: [],
      operationTypes: [
        {
          kind: Kind.OPERATION_TYPE_DEFINITION,
          operation: OperationTypeNode.QUERY,
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Query",
            },
          },
        },
        {
          kind: Kind.OPERATION_TYPE_DEFINITION,
          operation: OperationTypeNode.MUTATION,
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Mutation",
            },
          },
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value:
          "The query type, represents all of the entry points into our object graph",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Query",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "hero",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "episode",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Episode",
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Character",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "reviews",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "episode",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "Episode",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Review",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "search",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "text",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "String",
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "SearchResult",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "character",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "id",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "ID",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Character",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "droid",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "id",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "ID",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Droid",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "human",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "id",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "ID",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Human",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "starship",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "id",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "ID",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Starship",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value:
          "The mutation type, represents all updates we can make to our data",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Mutation",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "createReview",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "episode",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Episode",
                },
              },
              directives: [],
            },
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "review",
              },
              type: {
                kind: Kind.NON_NULL_TYPE,
                type: {
                  kind: Kind.NAMED_TYPE,
                  name: {
                    kind: Kind.NAME,
                    value: "ReviewInput",
                  },
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Review",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.ENUM_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "The episodes in the Star Wars trilogy",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Episode",
      },
      directives: [],
      values: [
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Star Wars Episode IV: A New Hope, released in 1977.",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "NEWHOPE",
          },
          directives: [],
        },
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "Star Wars Episode V: The Empire Strikes Back, released in 1980.",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "EMPIRE",
          },
          directives: [],
        },
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "Star Wars Episode VI: Return of the Jedi, released in 1983.",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "JEDI",
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.INTERFACE_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "A character from the Star Wars universe",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Character",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The ID of the character",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "id",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "ID",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The name of the character",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "name",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "String",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "The friends of the character, or an empty list if they have none",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friends",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Character",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "The friends of the character exposed as a connection with edges",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friendsConnection",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "first",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Int",
                },
              },
              directives: [],
            },
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "after",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "ID",
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "FriendsConnection",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The movies this character appears in",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "appearsIn",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.LIST_TYPE,
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Episode",
                },
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.ENUM_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "Units of height",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "LengthUnit",
      },
      directives: [],
      values: [
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The standard unit around the world",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "METER",
          },
          directives: [],
        },
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Primarily used in the United States",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "FOOT",
          },
          directives: [],
        },
        {
          kind: Kind.ENUM_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Ancient unit used during the Middle Ages",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "CUBIT",
          },
          directives: [
            {
              kind: Kind.DIRECTIVE,
              name: {
                kind: Kind.NAME,
                value: "deprecated",
              },
              arguments: [
                {
                  kind: Kind.ARGUMENT,
                  name: {
                    kind: Kind.NAME,
                    value: "reason",
                  },
                  value: {
                    kind: Kind.STRING,
                    value: "Test deprecated enum case",
                    block: false,
                  },
                },
              ],
            },
          ],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "A humanoid creature from the Star Wars universe",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Human",
      },
      interfaces: [
        {
          kind: Kind.NAMED_TYPE,
          name: {
            kind: Kind.NAME,
            value: "Character",
          },
        },
      ],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The ID of the human",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "id",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "ID",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "What this human calls themselves",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "name",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "String",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The home planet of the human, or null if unknown",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "homePlanet",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "String",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Height in the preferred unit, default is meters",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "height",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "unit",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "LengthUnit",
                },
              },
              defaultValue: {
                kind: Kind.ENUM,
                value: "METER",
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Float",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Mass in kilograms, or null if unknown",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "mass",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Float",
            },
          },
          directives: [
            {
              kind: Kind.DIRECTIVE,
              name: {
                kind: Kind.NAME,
                value: "deprecated",
              },
              arguments: [
                {
                  kind: Kind.ARGUMENT,
                  name: {
                    kind: Kind.NAME,
                    value: "reason",
                  },
                  value: {
                    kind: Kind.STRING,
                    value: "Weight is a sensitive subject!",
                    block: false,
                  },
                },
              ],
            },
          ],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "This human's friends, or an empty list if they have none",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friends",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Character",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "The friends of the human exposed as a connection with edges",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friendsConnection",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "first",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Int",
                },
              },
              directives: [],
            },
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "after",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "ID",
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "FriendsConnection",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The movies this human appears in",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "appearsIn",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.LIST_TYPE,
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Episode",
                },
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "A list of starships this person has piloted, or an empty list if none",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "starships",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Starship",
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "An autonomous mechanical character in the Star Wars universe",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Droid",
      },
      interfaces: [
        {
          kind: Kind.NAMED_TYPE,
          name: {
            kind: Kind.NAME,
            value: "Character",
          },
        },
      ],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The ID of the droid",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "id",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "ID",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "What others call this droid",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "name",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "String",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "This droid's friends, or an empty list if they have none",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friends",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Character",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "The friends of the droid exposed as a connection with edges",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friendsConnection",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "first",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Int",
                },
              },
              directives: [],
            },
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "after",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "ID",
                },
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "FriendsConnection",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The movies this droid appears in",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "appearsIn",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.LIST_TYPE,
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "Episode",
                },
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "This droid's primary function",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "primaryFunction",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "String",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "A connection object for a character's friends",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "FriendsConnection",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The total number of friends",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "totalCount",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Int",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The edges for each of the character's friends.",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "edges",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "FriendsEdge",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value:
              "A list of the friends, as a convenience when edges are not needed.",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "friends",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Character",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Information for paginating this connection",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "pageInfo",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "PageInfo",
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "An edge object for a character's friends",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "FriendsEdge",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "A cursor used for pagination",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "cursor",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "ID",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The character represented by this friendship edge",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "node",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Character",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "Information for paginating this connection",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "PageInfo",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "startCursor",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "ID",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "endCursor",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "ID",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "hasNextPage",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Boolean",
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "Represents a review for a movie",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "Review",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The number of stars this review gave, 1-5",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "stars",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Int",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Comment about the movie",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "commentary",
          },
          arguments: [],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "String",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "The input object sent when someone is creating a new review",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "ReviewInput",
      },
      directives: [],
      fields: [
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "0-5 stars",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "stars",
          },
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Int",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Comment about the movie, optional",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "commentary",
          },
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "String",
            },
          },
          directives: [],
        },
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Favorite color, optional",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "favorite_color",
          },
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "ColorInput",
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
      description: {
        kind: Kind.STRING,
        value: "The input object sent when passing in a color",
        block: true,
      },
      name: {
        kind: Kind.NAME,
        value: "ColorInput",
      },
      directives: [],
      fields: [
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "red",
          },
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Int",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "green",
          },
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Int",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.INPUT_VALUE_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "blue",
          },
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "Int",
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.OBJECT_TYPE_DEFINITION,
      name: {
        kind: Kind.NAME,
        value: "Starship",
      },
      interfaces: [],
      directives: [],
      fields: [
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The ID of the starship",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "id",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "ID",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "The name of the starship",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "name",
          },
          arguments: [],
          type: {
            kind: Kind.NON_NULL_TYPE,
            type: {
              kind: Kind.NAMED_TYPE,
              name: {
                kind: Kind.NAME,
                value: "String",
              },
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          description: {
            kind: Kind.STRING,
            value: "Length of the starship, along the longest axis",
            block: true,
          },
          name: {
            kind: Kind.NAME,
            value: "length",
          },
          arguments: [
            {
              kind: Kind.INPUT_VALUE_DEFINITION,
              name: {
                kind: Kind.NAME,
                value: "unit",
              },
              type: {
                kind: Kind.NAMED_TYPE,
                name: {
                  kind: Kind.NAME,
                  value: "LengthUnit",
                },
              },
              defaultValue: {
                kind: Kind.ENUM,
                value: "METER",
              },
              directives: [],
            },
          ],
          type: {
            kind: Kind.NAMED_TYPE,
            name: {
              kind: Kind.NAME,
              value: "Float",
            },
          },
          directives: [],
        },
        {
          kind: Kind.FIELD_DEFINITION,
          name: {
            kind: Kind.NAME,
            value: "coordinates",
          },
          arguments: [],
          type: {
            kind: Kind.LIST_TYPE,
            type: {
              kind: Kind.NON_NULL_TYPE,
              type: {
                kind: Kind.LIST_TYPE,
                type: {
                  kind: Kind.NON_NULL_TYPE,
                  type: {
                    kind: Kind.NAMED_TYPE,
                    name: {
                      kind: Kind.NAME,
                      value: "Float",
                    },
                  },
                },
              },
            },
          },
          directives: [],
        },
      ],
    },
    {
      kind: Kind.UNION_TYPE_DEFINITION,
      name: {
        kind: Kind.NAME,
        value: "SearchResult",
      },
      directives: [],
      types: [
        {
          kind: Kind.NAMED_TYPE,
          name: {
            kind: Kind.NAME,
            value: "Human",
          },
        },
        {
          kind: Kind.NAMED_TYPE,
          name: {
            kind: Kind.NAME,
            value: "Droid",
          },
        },
        {
          kind: Kind.NAMED_TYPE,
          name: {
            kind: Kind.NAME,
            value: "Starship",
          },
        },
      ],
    },
  ],
})