question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use source-graphql with prismic.io

See original GitHub issue

Hello 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jakedohmcommented, Oct 1, 2019

@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 the HttpLink. Then to configure the HttpLink, you’d do the following:

{
  use: '@gridsome/source-graphql',
  options: {
    httpLinkConfig: {
      useGETForQueries: true
    },
    // ...
  }
}

If that makes sense to y'all, I'll create an issue for this functionality, and implement soon 👍
1reaction
qdpycommented, Oct 3, 2019

Interested ! Can you PM me @Dansuncoin ? quentin[at]leasy.co

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Prismic with GraphQL Source Plugin - Gatsby
Used alongside Gatsby it lets you create fast, editable sites. Note that the Gatsby Prismic source plugin you will use during this tutorial,...
Read more >
Fetch Data with GraphQL - Documentation - Prismic
Every Prismic repository includes a GraphQL API explorer that will help you discover your API and test your queries: Copy https://your-repo-name.prismic.io/ ...
Read more >
Variable $uid not provided for root slug - Prismic People
I'm using Gatsby with gatsby-prismic-source-graphql and automatically generating pages from my custom types with slugs built as ...
Read more >
Prismic and GraphQL Overview - Documentation
This guide describes how to use Prismic's GraphQL API with React, but you can translate the examples and instructions to any other framework...
Read more >
How to introspect the GraphQL API - Developing with Prismic
Hello guys, I'm integrating Prismic with some projects using NextJS + ... Preparing request to https://my-app-dev.prismic.io/graphql Using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found