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?
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.
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
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
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.
@alws for what it’s worth, the Apollo toolset is a fairly common mechanism for interacting with GraphQL services. It’s a great sign that Prismic has an Apollo Link, but I think to fully benefit from the Apollo tools — even with the Apollo Link — we need to be able to interact with the Prismic API using the Apollo CLI tools.
Any chance one of you could take a quick look into this to see what modifications would be needed to get this working? We would all really appreciate it, and deep integration with Apollo could be a huge differentiator for Prismic.
We plan to make some improvement on the GraphQL API and a better support for this kind of tool will be part of it.
If you need an idea on when we plan to release this, maybe @renaud can already give you some more info
You can easily generate schema using https://graphql-code-generator.com/ CLI
with the following config:
I wish this would be documented in the guide, it took me half a day to figure that out, and I was very close to giving up on prismic and switching to GraphCMS