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

Graphql 17 support #185

Merged
merged 13 commits into from
Mar 13, 2023
Merged

Conversation

igrlk
Copy link
Contributor

@igrlk igrlk commented Nov 14, 2022

👋 Hi. I didn't get a response for this question about graphql@17 support and decided to go ahead and make graphql-jit work with the latest graphql-js

This PR stops using things that were deprecated in graphql@17 and doesn't add any new functionality like @defer support - thankfully graphql spec says that it's not required to support @stream/@defer directives to be fully spec compatible.

I think we don't need to merge it into main branch until graphql@17 is released

Happy to hear any feedback from the contributors on this. Cheers! 🎩

@oporkka
Copy link
Member

oporkka commented Jan 26, 2023

Thanks for your contribution @igrlk. We added already test runs for the alpha version of 17. It seems that the tests that run also with GraphQL 15 and GraphQL 16 need fixing. Do you want to look into it to add support for older versions? We have version-specific code in style

const context: any =
versionInfo.major > 15
? (buildExecutionContext as any)({
schema: blogSchema,
document
})
: (buildExecutionContext as any)(blogSchema, document);

@igrlk
Copy link
Contributor Author

igrlk commented Jan 27, 2023

@oporkka thanks for checking this PR! Yep I'm happy to fix the tests for other versions - would you mind allowing me to run the github checks? It will make the process faster :)

@igrlk
Copy link
Contributor Author

igrlk commented Jan 27, 2023

Hey @oporkka I was able to get the tests green on node 14, 16, 18 in combo with graphql 15, 16, 17 locally. Pushed all the changes to the branch

@oporkka
Copy link
Member

oporkka commented Jan 27, 2023

Tests allowed, but fail on coverage. I am not sure why they start failing after the change, is it actually the support for version info that causes the branch coverage to degrade? In any case, propose to lower the target for now to 91% to make all the tests run

@igrlk
Copy link
Contributor Author

igrlk commented Jan 27, 2023

Decreased the coverage threshold for branches to 91.

Still can't run the tests btw, looks like I need to become a contributor in the repo first to be able to run them

@igrlk
Copy link
Contributor Author

igrlk commented Jan 29, 2023

@oporkka thanks for running the tests. Since I've added the additional versionInfo.major checks and the package still works with the old versions of graphql, do you think it's something we can merge now? Would love to hear your thoughts on that :)

src/ast.ts Show resolved Hide resolved
import * as utilities from "graphql/error";
import { GraphQLFormattedError } from "graphql/error";

export const formatError = (error: GraphQLError): GraphQLFormattedError => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: please refactor to function declaration instead of using arrow function expression.

import { ASTNode } from "graphql/language/ast";
import { GraphQLError, versionInfo } from "graphql";

export const getGraphQLErrorOptions = (
Copy link
Member

Choose a reason for hiding this comment

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

move this to the src/compat.ts file

src/compat.ts Outdated
export const getOperationRootType = (
schema: GraphQLSchema,
operation: OperationDefinitionNode
): GraphQLObjectType => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: please refactor this arrow function expression to function declaration.

package.json Outdated
"functions": 96,
"lines": 96,
"statements": 96
}
}
},
"peerDependencies": {
"graphql": ">=15"
"graphql": ">=17"
Copy link
Member

Choose a reason for hiding this comment

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

This we should keep as >=15 for now, as we still support 15

package.json Outdated
@@ -72,7 +72,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-standard": "^5.0.0",
"graphql": "^16.0.0",
"graphql": "^17.0.0-alpha.2",
Copy link
Member

Choose a reason for hiding this comment

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

This could be also changed back to 16 before merging, as 17 is nevertheless still alpha. We will keep support in test runs, though.

src/ast.ts Show resolved Hide resolved
@igrlk
Copy link
Contributor Author

igrlk commented Jan 31, 2023

Thank you for your comments, @boopathi @oporkka. All the things you mentioned should be fixed now

@igrlk
Copy link
Contributor Author

igrlk commented Feb 1, 2023

Fixed the tests

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this file. I propose to have .idea/ in your global .gitignore file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for removing the file from the PR and for the global .gitignore suggestion :)

@oporkka
Copy link
Member

oporkka commented Feb 2, 2023

👍

@igrlk
Copy link
Contributor Author

igrlk commented Mar 10, 2023

Hi @boopathi @oporkka. Is there something that's blocking us from merging this PR? 😄

@boopathi
Copy link
Member

👍

@boopathi boopathi merged commit 3d2675a into zalando-incubator:main Mar 13, 2023
@oporkka
Copy link
Member

oporkka commented Mar 13, 2023

Is there something that's blocking us from merging this PR? 😄

@igrlk Sorry for the delay, we just forgot to follow up on this as other things popped up.

@boopathi boopathi mentioned this pull request Mar 13, 2023
@igrlk igrlk deleted the graphql-17-support branch March 13, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants