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

Auto-registration of @GraphQlRepository does not work for output type defined as non-null #418

Closed
NavidMitchell opened this issue Jun 17, 2022 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@NavidMitchell
Copy link

NavidMitchell commented Jun 17, 2022

First off, I want to say Thank you! for building Spring GraphQL I like the project and where it is headed! :)

If you take a look at the spring-graphql/samples/webmvc-http and you take the schema for the query defined as.

type Query {
    artifactRepositories : [ArtifactRepository]
}

And you change this to

type Query {
    artifactRepositories : [ArtifactRepository!]
}

The query will no longer return any results since the data fetcher will not be found anymore.

This appears to be a problem in org.springframework.graphql.data.query.AutoRegistrationRuntimeWiringConfigurer Line 87 is not unwrapping NotNull types.

GraphQLType outputType = (environment.getFieldType() instanceof GraphQLList ?
		((GraphQLList) environment.getFieldType()).getWrappedType() :
		environment.getFieldType());

Unless this was the desired result. If that is the case It would be nice to update the docs with a warning. I chased my tail for a while because I could not get any results. Since I had defined my queries with non null result types. Which I think is semantically correct for spring data.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 17, 2022
@rstoyanchev rstoyanchev added this to the Triage Queue milestone Jun 23, 2022
@bclozel
Copy link
Member

bclozel commented Jun 23, 2022

We might have to unwrap graphql.language.NonNullType

@NavidMitchell
Copy link
Author

@bclozel if you want I can submit a PR ?

@rstoyanchev
Copy link
Contributor

Sure, if you've identified the fix already, and adding a test as well would be great.

@NavidMitchell
Copy link
Author

Ok I will do this over the weekend.

@rstoyanchev rstoyanchev self-assigned this Jul 8, 2022
@rstoyanchev rstoyanchev added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 8, 2022
@rstoyanchev rstoyanchev modified the milestones: Triage Queue, 1.0.1 Jul 8, 2022
@rstoyanchev rstoyanchev changed the title @GraphQlRepository does not work properly if the GraphQL schema defines non null type. Auto-registration of @GraphQlRepository does not work for output type defined as non-null Jul 8, 2022
@rstoyanchev
Copy link
Contributor

Should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants