Skip to content

Commit

Permalink
chore(deps): update dependency graphql to v16 (main) (apollographql#1129
Browse files Browse the repository at this point in the history
)

* chore(deps): update dependency graphql to v16

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Chris Lenfest <clenfest@apollographql.com>
Co-authored-by: Trevor Scheer <trevor.scheer@gmail.com>
  • Loading branch information
4 people authored Jan 12, 2022
1 parent b1d9079 commit 8c4f0b3
Show file tree
Hide file tree
Showing 37 changed files with 5,671 additions and 10,478 deletions.
2 changes: 1 addition & 1 deletion composition-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"@apollo/query-graphs": "file:../query-graphs-js"
},
"peerDependencies": {
"graphql": "^15.7.0"
"graphql": "^15.7.0 || ^16.0.0"
}
}
2 changes: 1 addition & 1 deletion composition-js/src/__tests__/compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function assertCompositionSuccess(r: CompositionResult): asserts r is Compositio
}

function errors(r: CompositionResult): [string, string][] {
return r.errors?.map(e => [e.extensions.code, e.message]) ?? [];
return r.errors?.map(e => [e.extensions.code as string, e.message]) ?? [];
}

// Returns [the supergraph schema, its api schema, the extracted subgraphs]
Expand Down
2 changes: 1 addition & 1 deletion composition-js/src/__tests__/hints.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Subgraphs } from '@apollo/federation-internals';
import { DocumentNode } from 'graphql';
import { Subgraphs } from '@apollo/federation-internals';
import gql from 'graphql-tag';
import {
HintID,
Expand Down
12 changes: 6 additions & 6 deletions composition-js/src/merging/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
ErrorCodeDefinition,
ERRORS,
} from "@apollo/federation-internals";
import { ASTNode, GraphQLError, DirectiveLocationEnum } from "graphql";
import { ASTNode, GraphQLError, DirectiveLocation } from "graphql";
import {
CompositionHint,
HintID,
Expand Down Expand Up @@ -250,7 +250,7 @@ function hasTagUsage(subgraph: Schema): boolean {
return !!directive && directive.applications().length > 0;
}

function locationString(locations: DirectiveLocationEnum[]): string {
function locationString(locations: DirectiveLocation[]): string {
if (locations.length === 0) {
return "";
}
Expand Down Expand Up @@ -1340,7 +1340,7 @@ class Merger {

let repeatable: boolean | undefined = undefined;
let inconsistentRepeatable = false;
let locations: DirectiveLocationEnum[] | undefined = undefined;
let locations: DirectiveLocation[] | undefined = undefined;
let inconsistentLocations = false;
for (const source of sources) {
if (!source) {
Expand Down Expand Up @@ -1399,7 +1399,7 @@ class Merger {
private mergeExecutionDirectiveDefinition(sources: (DirectiveDefinition | undefined)[], dest: DirectiveDefinition) {
let repeatable: boolean | undefined = undefined;
let inconsistentRepeatable = false;
let locations: DirectiveLocationEnum[] | undefined = undefined;
let locations: DirectiveLocation[] | undefined = undefined;
let inconsistentLocations = false;
for (const source of sources) {
if (!source) {
Expand Down Expand Up @@ -1494,12 +1494,12 @@ class Merger {
}
}

private extractLocations(source: DirectiveDefinition): DirectiveLocationEnum[] {
private extractLocations(source: DirectiveDefinition): DirectiveLocation[] {
// We sort the locations so that the return list of locations essentially act like a set.
return this.filterExecutableDirectiveLocations(source).concat().sort();
}

private filterExecutableDirectiveLocations(source: DirectiveDefinition): readonly DirectiveLocationEnum[] {
private filterExecutableDirectiveLocations(source: DirectiveDefinition): readonly DirectiveLocation[] {
if (MERGED_TYPE_SYSTEM_DIRECTIVES.includes(source.name)) {
return source.locations;
}
Expand Down
2 changes: 1 addition & 1 deletion composition-js/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function validationError(
// involved though as there may be a lot of different reason why it doesn't validate. But by looking at the last edge on the
// supergraph and the subgraphsPath, we should be able to roughly infer what's going on.
const operation = print(operationToDocument(witness));
const message = `The following supergraph API query:\n${operation}`
const message = `The following supergraph API query:\n${operation}\n`
+ 'cannot be satisfied by the subgraphs because:\n'
+ displayReasons(subgraphsPathsUnadvanceables);
return new ValidationError(message, unsatisfiablePath, subgraphsPaths, witness);
Expand Down
2 changes: 1 addition & 1 deletion federation-integration-testsuite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"homepage": "https://github.com/apollographql/federation#readme",
"dependencies": {
"graphql-tag": "^2.10.4",
"graphql-tag": "^2.12.6",
"pretty-format": "^27.0.0"
}
}
4 changes: 2 additions & 2 deletions federation-integration-testsuite-js/src/utils/gql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from "graphql";
import { parse, Kind } from "graphql";
import stripIndent from 'strip-indent';
// This function signature is mostly lifted from the upstream `graphql-tag`.
// The motivation for this `gql` implementation is the desire to preserve
Expand All @@ -19,7 +19,7 @@ export function gql(
let result = literals[0];

args.forEach((arg, i) => {
if (arg && arg.kind === 'Document') {
if (arg && arg.kind === Kind.DOCUMENT) {
result += arg.loc.source.body;
} else {
result += arg;
Expand Down
2 changes: 2 additions & 0 deletions gateway-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Some defensive code around gateway shutdown has been removed which was only rele

[#1246](https://github.com/apollographql/federation/pull/1246)

Upgrading graphql dependency to `16.2.0` [PR #1129](https://github.com/apollographql/federation/pull/1129).

## v2.0.0-alpha.3

- RemoteGraphQLDataSource will now use `make-fetch-happen` by default rather than `node-fetch` [PR #1284](https://github.com/apollographql/federation/pull/1284)
Expand Down
2 changes: 1 addition & 1 deletion gateway-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"sha.js": "^2.4.11"
},
"peerDependencies": {
"graphql": "^15.7.0"
"graphql": "^15.7.0 || ^16.0.0"
}
}
2 changes: 1 addition & 1 deletion gateway-js/src/datasources/LocalGraphQLDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class LocalGraphQLDataSource<
throw new Error(result.errors.map((error) => error.message).join('\n\n'));
}

const sdl = result.data && result.data._service && result.data._service.sdl;
const sdl = result.data && result.data._service && (result.data._service as any).sdl;
return parse(sdl);
}
}
4 changes: 3 additions & 1 deletion gateway-js/src/executeQueryPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
GraphQLFormattedError,
isAbstractType,
GraphQLSchema,
isObjectType,
isInterfaceType,
} from 'graphql';
import { Trace, google } from 'apollo-reporting-protobuf';
import { GraphQLDataSource, GraphQLDataSourceRequestKind } from './datasources/types';
Expand Down Expand Up @@ -556,7 +558,7 @@ function doesTypeConditionMatch(
}

if (isAbstractType(conditionalType)) {
return schema.isSubType(conditionalType, type);
return (isObjectType(type) || isInterfaceType(type)) && schema.isSubType(conditionalType, type);
}

return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execute, GraphQLError, parse } from "graphql";
import { cleanErrorOfInaccessibleNames } from "../cleanErrorOfInaccessibleNames";
import { buildSchema } from "@apollo/federation-internals";
import { execute, GraphQLError, parse } from 'graphql';
import { cleanErrorOfInaccessibleNames } from '../cleanErrorOfInaccessibleNames';
import { buildSchema } from '@apollo/federation-internals';

describe('cleanErrorOfInaccessibleNames', () => {
const coreSchema = buildSchema(`
Expand Down Expand Up @@ -49,19 +49,22 @@ describe('cleanErrorOfInaccessibleNames', () => {
const schema = coreSchema.toAPISchema().toGraphQLJSSchema();

it('removes inaccessible type names from error messages', async () => {
const result = await execute(schema, parse('{fooField{someField}}'), {
fooField: {
__typename: 'Bar',
someField: 'test',
const result = await execute({
schema,
document: parse('{fooField{someField}}'),
rootValue: {
fooField: {
__typename: 'Bar',
someField: 'test',
},
},
});

const cleaned = cleanErrorOfInaccessibleNames(schema, result.errors![0]!);
expect(cleaned.message).toMatchInlineSnapshot(
`"Abstract type \\"Foo\\" was resolve to a type [inaccessible type] that does not exist inside schema."`,
`"Abstract type \\"Foo\\" was resolved to a type [inaccessible type] that does not exist inside the schema."`,
);
});

it('removes multiple/repeated inaccessible type names from error messages', async () => {
const contrivedError = new GraphQLError(
`Something something "Bar" and "Bar" again, as well as "Bar2".`,
Expand Down
2 changes: 1 addition & 1 deletion harmonizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"whatwg-url": "^11.0.0"
},
"peerDependencies": {
"graphql": "^15.7.0"
"graphql": "^15.7.0 || ^16.0.0"
}
}
2 changes: 1 addition & 1 deletion internals-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"access": "public"
},
"peerDependencies": {
"graphql": "^15.7.0"
"graphql": "^15.7.0 || ^16.0.0"
},
"devDependencies": {
"@types/js-levenshtein": "1.1.1"
Expand Down
2 changes: 1 addition & 1 deletion internals-js/src/__tests__/subgraphValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function buildForErrors(subgraphDefs: DocumentNode, subgraphName: string = 'S'):
if (!causes) {
throw e;
}
return causes.map((err) => [err.extensions.code, err.message]);
return causes.map((err) => [err.extensions.code as string, err.message]);
}
}

Expand Down
13 changes: 7 additions & 6 deletions internals-js/src/buildSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
DefinitionNode,
DirectiveDefinitionNode,
DirectiveLocationEnum,
DirectiveLocation,
DirectiveNode,
DocumentNode,
FieldDefinitionNode,
Expand All @@ -18,7 +18,8 @@ import {
StringValueNode,
ASTNode,
SchemaExtensionNode,
parseType
parseType,
Kind,
} from "graphql";
import { Maybe } from "graphql/jsutils/Maybe";
import {
Expand Down Expand Up @@ -332,11 +333,11 @@ export function builtTypeReference(encodedType: string, schema: Schema): Type {

function buildTypeReferenceFromAST(typeNode: TypeNode, schema: Schema): Type {
switch (typeNode.kind) {
case 'ListType':
case Kind.LIST_TYPE:
return new ListType(buildTypeReferenceFromAST(typeNode.type, schema));
case 'NonNullType':
case Kind.NON_NULL_TYPE:
const wrapped = buildTypeReferenceFromAST(typeNode.type, schema);
if (wrapped.kind == 'NonNullType') {
if (wrapped.kind == Kind.NON_NULL_TYPE) {
throw new GraphQLError(`Cannot apply the non-null operator (!) twice to the same type`, typeNode);
}
return new NonNullType(wrapped);
Expand Down Expand Up @@ -368,7 +369,7 @@ function buildDirectiveDefinitionInner(directiveNode: DirectiveDefinitionNode, d
buildArgumentDefinitionInner(inputValueDef, directive.addArgument(inputValueDef.name.value));
}
directive.repeatable = directiveNode.repeatable;
const locations = directiveNode.locations.map(({ value }) => value as DirectiveLocationEnum);
const locations = directiveNode.locations.map(({ value }) => value as DirectiveLocation);
directive.addLocations(...locations);
directive.description = directiveNode.description?.value;
directive.sourceAST = directiveNode;
Expand Down
Loading

0 comments on commit 8c4f0b3

Please sign in to comment.