Skip to content

chore: upgrade to graphql 15 #524

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

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"peerDependencies": {
"amplify-cli-core": "^3.0.0",
"amplify-headless-interface": "^1.13.1",
"graphql-transformer-core": "^7.2.1"
"graphql-transformer-core": "^7.6.6"
}
}
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"peerDependencies": {
"amplify-cli-core": "^3.0.0",
"graphql-transformer-core": "^7.2.1"
"graphql-transformer-core": "^7.6.6"
},
"jest": {
"verbose": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"@aws-amplify/appsync-modelgen-plugin": "2.3.2",
"@aws-amplify/graphql-docs-generator": "3.0.2",
"@aws-amplify/graphql-types-generator": "3.0.0",
"@graphql-codegen/core": "1.8.3",
"@graphql-codegen/core": "2.6.6",
"chalk": "^3.0.0",
"fs-extra": "^8.1.0",
"glob-all": "^3.1.0",
"glob-parent": "^6.0.2",
"graphql": "^14.5.8",
"graphql": "^15.5.0",
"graphql-config": "^2.2.1",
"inquirer": "^7.3.3",
"js-yaml": "^4.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/appsync-modelgen-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
},
"devDependencies": {
"@graphql-codegen/testing": "^1.17.7",
"graphql": "^14.5.8",
"@graphql-codegen/typescript": "^2.8.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this package used for? Looks like it is newly added.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test would fail with the following without including this.

FAIL src/__tests__/visitors/appsync-javascript-visitor.test.ts
  ● Test suite failed to run

    Cannot find module '@graphql-codegen/typescript' from '../../node_modules/@graphql-codegen/testing/cjs/resolvers-common.js'

I think GraphQL 14 may have included this dependency before.

"graphql": "^15.5.0",
"java-ast": "^0.1.0",
"ts-json-schema-generator": "1.0.0"
},
"peerDependencies": {
"graphql": "^14.5.8"
"graphql": "^15.5.0"
},
"typescript": {
"definition": "lib/index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-docs-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"clean": "rimraf ./lib"
},
"dependencies": {
"graphql": "^14.5.8",
"graphql": "^15.5.0",
"handlebars": "4.7.7",
"prettier": "^1.19.1",
"yargs": "^15.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-types-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"core-js": "^3.6.4",
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
"graphql": "^14.5.8",
"graphql": "^15.5.0",
"inflected": "^2.0.4",
"prettier": "^1.19.1",
"rimraf": "^3.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-types-generator/src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,5 @@ function wrapInBooleanConditionsIfNeeded(

return selection;
}

export type Maybe<T> = null | undefined | T;
8 changes: 4 additions & 4 deletions packages/graphql-types-generator/src/compiler/legacyIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { typeCaseForSelectionSet } from './visitors/typeCase';
import { collectAndMergeFields } from './visitors/collectAndMergeFields';

import '../utilities/array';
import Maybe from 'graphql/tsutils/Maybe';
import { Maybe } from './';

export interface CompilerOptions {
addTypename?: boolean;
Expand Down Expand Up @@ -91,7 +91,7 @@ export interface Argument {
export function compileToLegacyIR(
schema: GraphQLSchema,
document: DocumentNode,
options: CompilerOptions = { mergeInFieldsFromFragmentSpreads: true }
options: CompilerOptions = { mergeInFieldsFromFragmentSpreads: true },
): LegacyCompilerContext {
const context = compileToIR(schema, document, options);
const transformer = new LegacyIRTransformer(context, options);
Expand Down Expand Up @@ -164,7 +164,7 @@ class LegacyIRTransformer {
return undefined;

const fragmentSpreads: string[] = this.collectFragmentSpreads(selectionSet, variant.possibleTypes).map(
(fragmentSpread: FragmentSpread) => fragmentSpread.fragmentName
(fragmentSpread: FragmentSpread) => fragmentSpread.fragmentName,
);
return variant.possibleTypes.map(possibleType => {
return {
Expand All @@ -181,7 +181,7 @@ class LegacyIRTransformer {
}

const fragmentSpreads: string[] = this.collectFragmentSpreads(selectionSet).map(
(fragmentSpread: FragmentSpread) => fragmentSpread.fragmentName
(fragmentSpread: FragmentSpread) => fragmentSpread.fragmentName,
);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LegacyCompilerContext, LegacyInlineFragment, LegacyFragment, LegacyField, LegacyOperation } from '../compiler/legacyIR';
import { Maybe } from '../compiler';
import {
GraphQLError,
getNamedType,
Expand Down Expand Up @@ -26,7 +27,6 @@ import { CodeGenerator } from '../utilities/CodeGenerator';
import { interfaceDeclaration, propertyDeclaration, pickedPropertySetsDeclaration, Property } from './language';

import { typeNameFromGraphQLType } from './types';
import Maybe from 'graphql/tsutils/Maybe';

export function generateSource(context: LegacyCompilerContext) {
const generator = new CodeGenerator<LegacyCompilerContext>(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { LegacyInlineFragment } from '../compiler/legacyIR';
import { Maybe } from '../compiler';

import { pickedPropertyDeclarations } from './codeGeneration';
import { typeNameFromGraphQLType } from './types';

import { CodeGenerator } from '../utilities/CodeGenerator';
import { GraphQLType } from 'graphql';
import Maybe from 'graphql/tsutils/Maybe';

export interface Property {
fieldName?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-types-generator/src/typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function typeNameFromGraphQLType(
context: LegacyCompilerContext,
type: GraphQLType,
bareTypeName?: string | null,
nullable = true
nullable = true,
): string {
if (isNonNullType(type)) {
return typeNameFromGraphQLType(context, type.ofType, bareTypeName, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ exports[`JSON output should generate JSON output for a mutation with an enum and
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this extra field being added in the tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDepreacted became required on GraphQLField in version 15. So it now shows up on all fields including __typename. graphql/graphql-js#2469

I don't see this causing any issue though.

},
{
\\"responseName\\": \\"stars\\",
Expand Down Expand Up @@ -194,7 +195,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"id\\",
Expand Down Expand Up @@ -235,7 +237,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand All @@ -258,7 +261,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand Down Expand Up @@ -289,7 +293,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand Down Expand Up @@ -595,7 +600,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand All @@ -617,7 +623,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand Down Expand Up @@ -941,7 +948,8 @@ exports[`JSON output should generate JSON output for a query with an enum variab
\\"responseName\\": \\"__typename\\",
\\"fieldName\\": \\"__typename\\",
\\"type\\": \\"String!\\",
\\"isConditional\\": false
\\"isConditional\\": false,
\\"isDeprecated\\": false
},
{
\\"responseName\\": \\"name\\",
Expand Down
Loading