-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Removing deprecated methods from tests - part 1 #2930
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
Conversation
| ] | ||
| when: | ||
| def result = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema).build().execute(query, null, params).data | ||
| def result = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema).build().execute(query, null, params).data // Retain deprecated method for test coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be a pain but I think we should "retain the deprecated method coverage IN the test for that class
ex GraphQLTest say rather than some random other test
This was the scope of the "retained for deprecated reasons" will reside in the most logical spot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, makes it easier to find deprecated uses later
| Object get(DataFetchingEnvironment environment) { | ||
| Person source = environment.getSource() | ||
| DataLoaderRegistry dlRegistry = environment.getContext() | ||
| DataLoaderRegistry dlRegistry = environment.getGraphQlContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can this work??? a "context" could have been a DataLoaderRegistry but a GraphqlContext never is!??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvironment.getGraphQlContext().get("registry") ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope I was wrong, it should not work
| private void assertValidQuery(GraphQLSchema graphQLSchema, String query, Map variables = [:]) { | ||
| GraphQL graphQL = GraphQL.newGraphQL(graphQLSchema).build() | ||
| assert graphQL.execute(query, null, variables).errors.size() == 0 | ||
| assert graphQL.execute(query, null, variables).errors.size() == 0 // Retain deprecated method for test coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to its own home test - remove from here - make a new test in its home test
bbakerman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments about moving ghe deprecated methods to their "home test" as a geenral pattern
| * @deprecated use {@link #graphQLContext(GraphQLContext)} instead | ||
| */ | ||
| @Deprecated | ||
| @DeprecatedAt("2021-07-05") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context getter was deprecated on this date, for consistency, also deprecating the builder
| ] | ||
| ] | ||
| when: | ||
| def result = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema).build().execute(query, null, params).data // Retain deprecated method for test coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2932 will remove execute, I'll remove execute tests after that PR is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged
| * @deprecated use {@link #graphQLContext(GraphQLContext)} instead | ||
| */ | ||
| @Deprecated | ||
| @DeprecatedAt("2021-07-05") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice because this is when it was deprecated - albeit missed
| .query(query) | ||
| .root(new MutationSchema.SubscriptionRoot(6)) | ||
|
|
||
| def executionResult = GraphQL.newGraphQL(MutationSchema.schema).build().execute(executionInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THere will be some merge conflicts here
| def executionInput = ExecutionInput.newExecutionInput() | ||
| .query(query) | ||
| .root(GarfieldSchema.john) | ||
| def executionResult = GraphQL.newGraphQL(GarfieldSchema.GarfieldSchema).build().execute(executionInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge conflicts here as well I think
# Conflicts: # src/test/groovy/graphql/MutationTest.groovy # src/test/groovy/graphql/StarWarsQueryTest.groovy # src/test/groovy/graphql/UnionTest.groovy # src/test/groovy/graphql/normalized/ExecutableNormalizedOperationFactoryTest.groovy
Updating tests to move away from deprecated methods. I've left at least 1 usage to maintain coverage in the method's "home" test file.
Also deprecates the
ExecutionContextBuildercontextbuilder for consistency. The getter was deprecated long ago.This is part 1, more to come in another PR.