My Graph QL endpoint isn’t giving me the data I’d expect, could be that I’m on v1 as it’s an old repository
Hi @owennicol, every Prismic repository can use both the REST API v1 and v2. And the GraphQL API is separate from these. Can you share more information about the data you’re receiving and how it isn’t what you expect?
Hi @levi, thanks for responding so soon.
I’ve got website that I created around 3 years ago using Prismic, which uses slices, built using the old
prismicio npm module and the
Prismic.api method of fetching data.
I’ve been rebuilding the website, looking to use the GraphQL API and struggling to get to the same content as before.
This is my GQL endpoint with a basic query:
and here’s my API/v2
What I need is a way to get to the
contentArea slices of the CaseStudy type but it alludes me with the GQL pre-defined queries, which was easy with the Rest API
Okay, I can see what the issue is here. The problem is that the GraphQL API isn’t able to handle fields that have any uppercase letters in them. For example, your field with the API ID of “contentArea” won’t appear in the GraphQL API. In order for a field like this to be available via GraphQL, you will need to recreate it using only lowercase letters. I’m very sorry for the inconvenience with this, but there is no other way to do this with the Prismic GraphQL API.
Just so you and others who might look at this thread are aware there is another particularity to GraphQL and the field API IDs: It isn’t proper GraphQL syntax to include dashes “-”, so our dev team removed them. This is why a field with an API ID of “image-gallery” would appear as “imageGallery” in the GraphQL API.
In any case, I’ll let the @features-team know about this so that they can consider improving this in the future.
I see, thank you very much for the diagnosis and advice @levi
I think that would be a really good idea to suggest they add as a “feature”.
I’m a little confused that they can change
imageGallery (which as you say isn’t valid GraphQL) but can’t deal with
It looks like I’ll be unable to use the GraphQL API in this instance, but it’s good to bear in mind for the future.
Thanks very much.