Skip to content

WIP Resolve GraphQL introspection issue (#69) via schema merging #255

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mirolimsgd
Copy link
Contributor

Okay, here's a draft Pull Request description based on the contributing guide and your git log. Adapt it as needed.

Title: fix: Resolve GraphQL introspection issue (#69) via build-time schema merging

Description:

Problem:

Resolves #69. The previous method of registering GraphQL schemas from different modules solely at runtime (app.RegisterGraphSchema) prevented standard GraphQL introspection tools (like Postman, Insomnia, etc.) from obtaining the complete API schema. This significantly hindered frontend development and testing workflows, as developers couldn't easily explore the available types, queries, and mutations or use features like auto-completion.

Solution:

This PR introduces a hybrid approach using build-time schema merging to enable correct introspection:

Primary Benefit:

Working Introspection: The GraphQL endpoint (/query) now correctly serves the full, combined schema from all modules when introspected by standard tools.

!!! Important Workflow Limitation & Contributing !!!

While introspection is fixed, the server currently still uses the module-specific schemas loaded via app.RegisterGraphSchema at runtime for actual query execution (this maintains the existing execution path).

Because of this hybrid setup and the use of a simple concatenation script:

Manual Step Required for go generate: Before running go generate ./graph/..., developers MUST temporarily comment out duplicate common definitions (e.g., scalar Time, scalar Int64, base type Query {}) in the source .graphql files of non-core modules (like warehouse).
Manual Step Required After go generate: After go generate completes successfully, developers MUST uncomment those definitions back in the source module files so that runtime schema registration (app.RegisterGraphSchema) functions correctly for each module.

This comment/uncomment process is necessary with the current approach. Please refer to the CONTRIBUTING.md guide (added in commit 8023547) for detailed steps on how to add or modify GraphQL fields under this new workflow.

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.

GraphQL introspection does not work on merged schemas
2 participants