Use source-graphql with prismic.io
See original GitHub issueHello there !
First thing first : Gridsome is awesome !
Summary
I was giving a try to prismic.io as a CMS for my Gridsome App. Prismic API endpoint is available in many technology as JavaScript, Node.js, JSON but also GraphQL (Introduction to the Prismic GraphQL API).
I’ve tried to ping the GraphQL API with the source-graphql plugin but it fails because
contrary to a classic GraphQL API, you need to use a GET request to query the Prismic GraphQl API.
To achieve this, you only need to set useGETForQueries : true
when you create the HttpLink
like this : const http = new HttpLink({ uri, useGETForQueries: true, fetch })
So it could be great if the request methods could be an option or something ?
Edit : It might be related to this issue : https://github.com/gridsome/gridsome/issues/116
Basic example
{
use: '@gridsome/source-graphql',
options: {
url: process.env.PRISMICIO_API_URL,
fieldName: 'prismicio',
typeName: 'prismicio',
method: 'GET',
headers: {
'Prismic-Ref': process.env.PRISMICIO_REF,
'Authorization': `Token ${process.env.PRISMICIO_API_TOKEN}`,
}
}
}
Motivation
I think this could be good because it will avoid to create and maintain another plugin for such a slight change. But maybe there are other consequences I don’t know for now…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top GitHub Comments
@hjvedvik hey! I totally understand how adding this would be helpful.
Here’s my recommendation for how we add configuration: Add a
httpLinkConfig
option, that accepts an object that will be merged with our configuration for theHttpLink
. Then to configure theHttpLink
, you’d do the following:Interested ! Can you PM me @Dansuncoin ? quentin[at]leasy.co