Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateSchemaHash: changes necessary for graphql@16.0.0 #5664

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/apollo-server-core/src/utils/schemaHash.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { parse } from 'graphql/language';
import { execute, ExecutionResult } from 'graphql/execution';
import { getIntrospectionQuery, IntrospectionSchema } from 'graphql/utilities';
import { getIntrospectionQuery, IntrospectionQuery } from 'graphql/utilities';
import stableStringify from 'fast-json-stable-stringify';
import { GraphQLSchema } from 'graphql/type';
import createSHA from './createSHA';
import { SchemaHash } from 'apollo-server-types';

export function generateSchemaHash(schema: GraphQLSchema): SchemaHash {
const introspectionQuery = getIntrospectionQuery();
const documentAST = parse(introspectionQuery);
const result = execute(schema, documentAST) as ExecutionResult;
const document = parse(introspectionQuery);
const result = execute({
schema,
document,
}) as ExecutionResult<IntrospectionQuery>;

// If the execution of an introspection query results in a then-able, it
// indicates that one or more of its resolvers is behaving in an asynchronous
Expand All @@ -32,7 +35,7 @@ export function generateSchemaHash(schema: GraphQLSchema): SchemaHash {
throw new Error('Unable to generate server introspection document.');
}

const introspectionSchema: IntrospectionSchema = result.data.__schema;
const introspectionSchema = result.data.__schema;

// It's important that we perform a deterministic stringification here
// since, depending on changes in the underlying `graphql-js` execution
Expand Down