Skip to content

Ensure NormalizedQueryTreeFactory handles mutations and subscriptions#2126

Closed
skevy wants to merge 1 commit into
graphql-java:masterfrom
skevy:fix/2117
Closed

Ensure NormalizedQueryTreeFactory handles mutations and subscriptions#2126
skevy wants to merge 1 commit into
graphql-java:masterfrom
skevy:fix/2117

Conversation

@skevy
Copy link
Copy Markdown

@skevy skevy commented Dec 7, 2020

Fixes #2117

Copy link
Copy Markdown
Member

@andimarek andimarek left a comment

Choose a reason for hiding this comment

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

Thanks a lot .. great PR. Please have a look at the comments.

} else if (operationDefinition.getOperation() == OperationDefinition.Operation.SUBSCRIPTION) {
rootType = graphQLSchema.getSubscriptionType();
} else {
throw new IllegalStateException("Operation type is not valid.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We use normally Assert.assertShouldNeverHappen here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello Andreas,
Assert.assertShouldNeverHappen seems to not work here as compiler complains that rootType is not initialized. And it looks like a good compile time check.
Can we commit this (as original author seems to be not available) as is? And replace this exception with something like

// Don't use Assert.assertShouldNeverHappen to make sure compiler does not force
// rootType above to be initialized. That way if code structure changes, compiler will
// catch that. Otherwise, we'd get NullPointerException at runtime.
throw new AssertException(
        String.format(
                "Internal error: should never happen: Operation type '%s' is not valid.",
                operationDefinition.getOperation()));

in a follow up PR?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@andimarek thoughts?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 to commit, I'm hitting this issue as well. How about using a return statement to get rid of the initialization issue:

return Assert.assertShouldNeverHappen("Operation type is not valid.");

coordinatesToNormalizedFields[coordinates("Foo", "subFoo")].size() == 2
}

def "handles mutations"() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another test for Subscriptions would be awesome, but Mutation is good enough.

@andimarek
Copy link
Copy Markdown
Member

superseded by #2173

@andimarek andimarek closed this Feb 1, 2021
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.

DataFetchingEnvironment.getSelectionSet().getFields() is broken from Mutations after upgrade to graphql-java 16

4 participants