# How to properly use the graphql-request library

**URL:** <https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515>\
**Category:** Developing with Prismic\
**Tags:** graphql\
**Created:** [October 18, 2021, 7:45pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515 "2021-10-18T19:45:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwatakeshi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/iwatakeshi/32/108_2.png) [@iwatakeshi](https://community.prismic.io/u/iwatakeshi)\
**Post date:** [October 18, 2021, 7:45pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/1 "2021-10-18T19:45:33Z")

</div>

Hi, I'm trying to use the [`graphql-request`](https://github.com/prisma-labs/graphql-request) library but I'm getting an error that says `...not a valid key=value pair (missing equal-sign) in Authorization header: 'Token ...'`.

The code in question looks something like this:

```auto
  const client = new GraphQLClient('https://my-repo.prismic.io/graphql', {
    headers: {
      'Prismic-Ref': 'ref', // manually added for now
      "Authorization": `Token ${process.env.PRISMIC_API_TOKEN}` // properly loaded env via '.env.local'
    }
  })

  // ... some lines of code that does the request

```

The framework I'm using is Next.js so assume that this is called on the server-side.

My goal is to be able to use `graphql-request` along with [`react-query`](https://react-query.tanstack.com/) from generated code ([`graqphl-codegen`](https://graphql-code-generator.com/)).

Would anyone be able help me? Thank you.

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [October 18, 2021, 9:16pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/2 "2021-10-18T21:16:22Z")

</div>

Hello @iwatakeshi, have you tried using our dedicated Prismic-Apollo Link? It allows you to query the Prismic GraphQL API with [apollo-client](https://www.apollographql.com/client/):

You can see an example of how a query is made using this kit, here:

> **[Integrating Prismic's GraphQL API with an existing Javascript Project](https://prismic.io/docs/technologies/integrate-with-existing-js-project-graphql#3.1-define-your-apollo-link)**
>
> The basic steps you need to take to integrate Prismic with an existing JavaScript Project using the GraphQL API.

---

<div class="post-metadata">

**Author:** ![iwatakeshi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/iwatakeshi/32/108_2.png) [@iwatakeshi](https://community.prismic.io/u/iwatakeshi)\
**Post date:** [October 18, 2021, 9:39pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/4 "2021-10-18T21:39:07Z")

</div>

Hi @Pau, thank you for the reply. Yes, I have used Apollo before, but I thought to try out another library and compare the speed of development. I guess I could use Apollo, but I thought to ask in case anyone has experience with `graphql-request`.

Another thing I realized is that this issue also occurs when I configure an IntelliJ plugin called `JS GraphQL`.

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [October 21, 2021, 11:46pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/5 "2021-10-21T23:46:57Z")

</div>

I see. Thanks for sharing. Unfortunately, at the moment, we don't have a working example that uses graphql-request.

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [October 25, 2021, 7:17pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/6 "2021-10-25T19:17:37Z")

</div>

This thread has been closed due to inactivity. [Flag to reopen](https://community.prismic.io/t/re-open-a-thread/2175).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [November 11, 2021, 8:18pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/7 "2021-11-11T20:18:25Z")

</div>



---

<div class="post-metadata">

**Author:** ![scubillos](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@scubillos](https://community.prismic.io/u/scubillos)\
**Post date:** [November 11, 2021, 8:20pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/8 "2021-11-11T20:20:19Z")

</div>

It happens when the /graphql pathname concatenates the queryString with a "/"

i.e. https://...prismic.io/graphql/?query=... instead of https://...prismic.io/graphql?query=...

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [November 12, 2021, 10:41pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/11 "2021-11-12T22:41:57Z")

</div>

Hey @scubillos, thanks for joining the conversation

Yes, maybe you need to manually add the Prismic GraphQL endpoint not to add that additional slash.

---

<div class="post-metadata">

**Author:** ![scubillos](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@scubillos](https://community.prismic.io/u/scubillos)\
**Post date:** [November 13, 2021, 12:42am UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/12 "2021-11-13T00:42:49Z")

</div>

That's right. You have to avoid that

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [November 13, 2021, 2:49am UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/13 "2021-11-13T02:49:01Z")

</div>

Thanks for sharing that @scubillos.

---

<div class="post-metadata">

**Author:** ![lpender](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/lpender/32/3643_2.png) [@lpender](https://community.prismic.io/u/lpender)\
**Post date:** [July 8, 2022, 9:28pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/18 "2022-07-08T21:28:55Z")

</div>

This might be helpful:

> **[The missing Prismic Documentation - HackMD](https://hackmd.io/Bgvx5n4dSvSKwOvFQXYgyA)**

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [July 11, 2022, 12:35pm UTC](https://community.prismic.io/t/how-to-properly-use-the-graphql-request-library/7515/19 "2022-07-11T12:35:24Z")

</div>

Thanks for sharing, @lpender.
