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

fix: Introspection query should succeed when only mutations exist #558

Conversation

mattjohnsonpint
Copy link
Member

Description

If you only define a function that is a mutation (ex: CreateProduct), then the generated GraphQL schema won't have a Query type. Since that would be invalid by the GraphQL spec, introspection queries would fail.

However, because we use GraphQL Go Tools, and it normalizes the schema when parsed, the introspection does end up getting a Query type added - so introspection should pass. However, it adds the type with "fields": null instead of "fields": [] - which is failing in Postman with:

image

It could be that Postman is pickier than it needs to be, but it still is in the way.

Ideally this would be fixed upstream in GraphQL Go Tools. I'll send a PR there. But in the meantime we can patch the outgoing introspection response.

Checklist

  • Code compiles correctly and linting passes locally
  • Entry added to the CHANGELOG.md file describing and linking to this PR

Sorry, something went wrong.

@mattjohnsonpint mattjohnsonpint requested a review from a team as a code owner November 6, 2024 00:02
@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) November 6, 2024 00:04
@mattjohnsonpint mattjohnsonpint merged commit 169ad1b into main Nov 6, 2024
45 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-2553-input-types-of-objects-to-functions-not-working-in-modus branch November 6, 2024 00:07
@mattjohnsonpint mattjohnsonpint changed the title Fix introspection query when only mutations exist fix: Introspection query should succeed when only mutations exist Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants