Hi Folks, I using Graphql to query my Prismic repo for all instances of a custom type. We would rather not install Apollo Client and Prismic Apollo for a request or two, so I am just making the requests using Fetch. I added a new instance of our Clue custom type and successfully queried it in the Graphql explorer.
I then temporarily installed Apollo Client and Prismic Apollo, made the request in our app with Apollo and the Graph query copied from the Graphql Explorer, and saw the data returned successfully. I then copied the request in the Network tab as a Fetch request, integrated that format into our app, and was able to retrieve the data using Fetch.
And then added a few more instances of this custom Clue type, but they are not coming back in my Fetch request. I am still seeing the older data. I see them returned in the Graphql explorer, and if I make the request in our app using Apollo as well. But I need to be using Fetch, is there something I am missing here? I newer to Graphql. Thanks!
This looks to be the same one that is used in the Graphql explorer when I inspect the network request. Interestingly enough this morning my Fetch request looks to be returning the correct data. Is there some sort of delay from when I publish in Prismic to when the Graph endpoint returns the updated data? Or some sort of cache I have to invalidate or something else I have to do? Thanks!
Can you try to remove the ref in your query, as you know if you query Prismic without a ref then it will default to the master ref.
The ref changes dynamically so you don't want to hardcode it.
Fares, I think I may have this figured out, unless you have a better way. I saw in the docs I can make a query to get the master ref, so I just do that each time before making the Graphql request, then include it in the request.
Unless there is some way to tell it to use the master ref by default.
Hi @anton1, I think the way you are doing 2 queries is the right way; in fact, I thought that master ref is provided by default which I found is not the case when I had discussed it with our dev team.
The first call to
/app
It is necessary to get a ref even in the case of a master ref for many reasons, including handing cashing.
To learn more about the rest of API, you can follow this document.
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
11
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.