Skip to content

Commit

Permalink
Specify graphql type where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
wlee221 committed Oct 5, 2021
1 parent c700189 commit ec78195
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/api-graphql/src/GraphQLAPI.ts
Expand Up @@ -12,7 +12,7 @@
*/
import { GraphQLError } from 'graphql/error/GraphQLError';
// @ts-ignore
import { OperationDefinitionNode } from 'graphql/language';
import { DocumentNode, OperationDefinitionNode } from 'graphql/language';
import { print } from 'graphql/language/printer';
import { parse } from 'graphql/language/parser';
import Observable from 'zen-observable-ts';
Expand Down Expand Up @@ -203,9 +203,10 @@ export class GraphQLAPIClass {
*/
getGraphqlOperationType(operation) {
const doc = parse(operation);
const {
definitions: [{ operation: operationType }],
} = doc;
const definitions = doc.definitions as ReadonlyArray<
OperationDefinitionNode
>;
const [{ operation: operationType }] = definitions;

return operationType;
}
Expand Down Expand Up @@ -294,7 +295,7 @@ export class GraphQLAPIClass {
};

const body = {
query: print(query),
query: print(query as DocumentNode),
variables,
};

Expand Down Expand Up @@ -389,7 +390,7 @@ export class GraphQLAPIClass {
appSyncGraphqlEndpoint,
authenticationType,
apiKey,
query: print(query),
query: print(query as DocumentNode),
region,
variables,
graphql_headers,
Expand Down

0 comments on commit ec78195

Please sign in to comment.