GraphQL API introspecton/codegen

I wanted to hook up codegen for my Prismic repository types in a NextJS app, but introspection might not be supported? Is this feature planned?

1 Like

Got the same question. Have you figured it out?

Not yet. A wild (or not so wild) idea would be to spin up your own graphql server and use schema stitching. Don’t know if that’ll work for sure though.

Quite wild indeed. I came up with another wild quick solution. I used Altair GraphQL Client to manually download the schema and then add it to my project. Then I can generate typing with apollo-codegen. It’s ugly but it works fine if you don’t change schema too often. But, tbh, introspection should be supported by Prismic. It’s an essential feature.

Hey guys,
The introspection query is there and is used for the graphiQL interface when you hit /graphql in your browser.
But for now it’s not conventional since Prismic relies on GET request but also requires to specify the ref with the header Prismic-Ref.
That’s why this kind of tool doesn’t work out of the box but if you can configure it with GET and the ref in the headers that should work.
We plan to improve this part and make it compatible with this kind of codeGen/Types plugins.
Hope it helps :wink:

1 Like

Hey Arnaud! Thanks for the reply.
Could you be more specific? How do I configure it to be a GET? Right now I got this:

"download-schema": "apollo client:download-schema schema.graphql --endpoint https://NAME.prismic.io/graphql --header 'Prismic-Ref: REF'"

I don’t know about your plugin specifically the config that you need to make but I wanted to give you the general spec to follow if you want to achieve it.
Some plugin don’t even let you use GET over POST.