Sorry for the silly question, I’m new to all this and this is my last resort… I haven’t received any answers on Discords and the like.
I want to set up a Strapi CMS with GraphQL for a Nuxt 3 frontend. I’ve successfully hosted this on DigitalOcean – the connection is established correctly and the API works flawlessly.
However, during development, my Nuxt 3 frontend naturally wants to constantly read the GraphQL schema via "nuxt prepare" using introspection. But this is by default turned off in Strapi’s production environment.
Unfortunately, I can’t manage to enable this manually – and actually, you’re not supposed to do that.
How is the workflow designed in such a case? Can the schema be pulled or extracted from somewhere else and provided to the Nuxt application? Should this perhaps be done via role-based permissions?
What I tried before:
Tried to write a ./config/plugins.ts according to the https://docs.strapi.io/dev-docs/plugins/graphql Documentation. Like that:
export default () => ({ graphql: { enabled: true, config: { playgroundAlways: true, apolloServer: { introspection: true, } }, }, });
It did not work. Tried the hardcode method like that but also with environment variables to quickly set the values in DigitalOcean. The file is correctly read and can be accessed with the console – but the introspection is still always prohibited.
Testing Method:
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ __schema { types { name } } }" }' MY_API_URL_WAS_HERE
Result always:
{"errors":[{"message":"GraphQL introspection is not allowed by Apollo Server, but the query contained __schema or __type. To enable introspection, pass introspection: true to ApolloServer in production","locations":[{"line":1,"column":3}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}]}
Also tried to put the file in ./config/env/production/plugins.ts but that also did not work.