Prisma 1 Forum

Authorization with graphql-request

I build a GraphQL API in AWS API Gateway, and I’m able to make HTTP requests queries in it with Postman, and axios. Like this example) http://myapi/graphql?query={me{name}}

I’m having trouble making a successful query in graphql-request. This is what I have, am I doing something wrong?

`const gqlRequest = require(‘graphql-request’)

let token = myToken

async function main() {
const endpoint = “API-gateway-invokeURL/graphql”

const graphQLClient = new gqlRequest.GraphQLClient(endpoint, {
headers: {
authorization: Bearer ${token},

const query = query{getBooks{author}}

const data = await graphQLClient.request(query)
console.log(JSON.stringify(data, undefined, 2))

main().catch(error => console.error(error))`

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.