I’m running a DigitalOcean App as our team’s backend dev server so that the frontend team doesn’t need to keep pulling updates from the backend, but I need to expose the API schema (ie graphql playground). But I’m not sure how to do it. We can query the backend just fine but we are accustomed to navigating to the api endpoint URL to view the available Schema. Any help is appreciated. I have this defined in my spec file:
ingress:
rules:
- component:
name: frontend
match:
path:
prefix: /
- component:
name: backend
preserve_path_prefix: true
match:
path:
prefix: /admin
- component:
name: backend
preserve_path_prefix: true
match:
path:
prefix: /admin-api
- component:
name: backend
preserve_path_prefix: true
match:
path:
prefix: /health
- component:
name: backend
preserve_path_prefix: true
match:
path:
prefix: /shop-api
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey 👋
As far as I can tell, at least based on the ingress rules you’ve provided, it looks like that you’re already routing different paths to your backend component.
So to expose the GraphQL playground, you’ll need to add another ingress rule that routes to the specific endpoint where your GraphQL playground is served.
Usually the GraphQL playgrounds are served at
/graphql
or/graphiql
I think. Assuming your backend serves the playground at/graphql
, you could add a rule like this:This rule would route requests to
/graphql
to your backend component, where the GraphQL playground should be served.If your GraphQL playground is served at a different path, adjust the
prefix
accordingly.Also, make sure that your backend is configured to serve the GraphQL playground in your production/staging environment. As far as I remember some frameworks disable it by default in non-development environments for security reasons.
If you’re using Apollo Server, for example, you might need to explicitly enable it:
One thing to keep in mind is that exposing GraphQL playgrounds in production environments can pose security risks, so make sure that you are not exposing any sensitive information.
- Bobby