Skip to content

Conversation

@dondonz
Copy link
Member

@dondonz dondonz commented Aug 21, 2022

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 ExecutionContextBuilder context builder for consistency. The getter was deprecated long ago.

This is part 1, more to come in another PR.

]
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
Copy link
Member

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

Copy link
Member Author

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()
Copy link
Member

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!??

Copy link
Member

Choose a reason for hiding this comment

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

nvironment.getGraphQlContext().get("registry") ??

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member

@bbakerman bbakerman left a 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

@dondonz dondonz marked this pull request as draft August 22, 2022 03:08
* @deprecated use {@link #graphQLContext(GraphQLContext)} instead
*/
@Deprecated
@DeprecatedAt("2021-07-05")
Copy link
Member Author

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
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

merged

@dondonz dondonz marked this pull request as ready for review August 22, 2022 21:16
* @deprecated use {@link #graphQLContext(GraphQLContext)} instead
*/
@Deprecated
@DeprecatedAt("2021-07-05")
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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
@dondonz dondonz added this to the 20.0 milestone Aug 23, 2022
@dondonz dondonz added not release related changes which are not released (for example unit tests or docs) and removed not release related changes which are not released (for example unit tests or docs) labels Aug 23, 2022
@dondonz dondonz merged commit 622ed4d into master Aug 23, 2022
@dondonz dondonz deleted the tests-deprecation-cleanout branch August 23, 2022 06:00
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