Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(graphql): make introspection configurable for dev vs prod environments - #9

Open
hosseiw wants to merge 1 commit into
rasadov:masterfrom
hosseiw:feat/configurable-graphql-introspection
Open

feat(graphql): make introspection configurable for dev vs prod environments#9
hosseiw wants to merge 1 commit into
rasadov:masterfrom
hosseiw:feat/configurable-graphql-introspection

Conversation

@hosseiw

@hosseiw hosseiw commented Sep 8, 2026

Copy link
Copy Markdown

Description

This PR implements configurable GraphQL introspection for the API gateway. Previously, introspection was disabled globally because srv.Use(extension.Introspection{}) was not registered on the handler.New(...) server, preventing GraphQL Playground and GraphiQL from loading the schema and documentation.

Changes

  • Environment & Introspection Configuration (graphql/config/config.go):
    • Added Environment resolution from ENVIRONMENT, APP_ENV, or ENV (defaults to development).
    • Set EnableIntrospection to default to true in development/local environments and false in production (ENVIRONMENT=production or prod).
    • Added support for explicit flag overrides via ENABLE_INTROSPECTION and INTROSPECTION_ENABLED (true/false, 1/0).
  • Conditional Introspection Extension (graphql/cmd/graphql/main.go):
    • Added newGraphQLHandler to conditionally attach extension.Introspection{}.
    • Added HTTP GET and OPTIONS endpoints for standard GraphQL HTTP spec compliance.
    • Logged active environment and introspection status on startup.
  • Docker Compose & Docs:
    • Configured ENVIRONMENT: development in docker-compose.yaml.
    • Documented environment variables in README.md.
  • Tests:
    • Added unit tests in graphql/config/config_test.go covering environment resolution, defaults, and flag precedence.
    • Added HTTP tests in graphql/cmd/graphql/main_test.go verifying schema introspection succeeds when enabled and fails when disabled.

…nments

- Add Environment and EnableIntrospection resolution in graphql/config

- Enable introspection by default in development/local and disable in production

- Support explicit overrides via ENABLE_INTROSPECTION and INTROSPECTION_ENABLED

- Wire extension.Introspection conditionally in graphql/cmd/graphql

- Add HTTP GET and OPTIONS routes for GraphQL compliance

- Document introspection config in README.md and docker-compose.yaml

- Add comprehensive unit tests for config resolution and introspection handling
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.

1 participant