Skip to content

DictionaryResolverType should not use cached types as SchemaTransformation can modify schema objects. #592

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

Closed
timward60 opened this issue Oct 8, 2021 · 4 comments · Fixed by #593
Labels

Comments

@timward60
Copy link
Contributor

timward60 commented Oct 8, 2021

Description

The DictionaryResolverType was returning GraphQL Schema Objects from a cache, however if the shema is transformed by SchemaTransformer, these GraphQL Schema Objects can change.

As such we should resolve the GraphQLObjectType from the schema object rather than a local cache.

Expected behavior

The DictionaryResolverType should return the same GraphQLObjectType instance as referenced in the schema.

Actual behavior

The DictionaryResolverType returns a different instance GraphQLObjectType than the schema if it was transformed.

Steps to reproduce the bug

https://github.com/timward60/graphql-java-tools/tree/timward/bug-592

    @Test
    fun `transformed schema should execute query`() {
        val transformedSchema = SchemaTransformer().transform(schema, Transformer())
        val transformedGql: GraphQL = GraphQL.newGraphQL(transformedSchema)
                .queryExecutionStrategy(AsyncExecutionStrategy())
                .build()

        val data = assertNoGraphQlErrors(transformedGql) {
            """
            {
                otherUnionItems {
                    ... on Item {
                        itemId: id
                    }
                    ... on ThirdItem {
                       thirdItemId: id
                    }
                }
            }
            """
        }

        assertEquals(data["otherUnionItems"], listOf(
                mapOf("itemId" to 0),
                mapOf("itemId" to 1),
                mapOf("thirdItemId" to 100)
        ))
    }
@timward60
Copy link
Contributor Author

@oryan-block Thanks for reviewing.

Any idea when a new release with this fix will be published to maven central?

@oryan-block
Copy link
Collaborator

@timward60 There isn't one planned but if you need it soon I can try to do one when I get a chance.

@timward60
Copy link
Contributor Author

@timward60 There isn't one planned but if you need it soon I can try to do one when I get a chance.

That would be appreciated, we are hoping to avoid using our private fork.

@oryan-block
Copy link
Collaborator

@timward60 12.0.1 release is out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants