Graphql-playground: Can you query an AWS AppSync API from GraphQL PlayGround?

Created on 20 Sep 2018  路  2Comments  路  Source: graphql/graphql-playground

Hey guys,

I would love to use the Playground for test queries and such. Any experience in setting this up? AWS AppSync gives you a config file in the following format, but I suspect this is wired to AWS's Apollo Client and probably not something you can use as a generic URL endpoint with Playground:

export default {
    "graphqlEndpoint": "https://12345.appsync-api.region-code.amazonaws.com/graphql",
    "region": "region-code",
    "authenticationType": "API_KEY",
    "apiKey": "12345"
}

When you try to enter the endpoint, you get the following error message:

{
  "error": "Response not successful: Received status code 401"
}

I tried to paste parts of the config file to the HTTP headers, but that didn't help either (no idea how to format that though). Any ideas?

Most helpful comment

Looking a the AWS AppSync docs for API_KEY, you pass the key in a header called x-api-key:

Using the 'Http Headers' section of GraphQL Playground, it appears it wants the headers as a JSON object:

{
  "x-api-key": "da2-FOOMYKEY"
}

This seemed to allow me to successfully query my API.

It would probably make peoples lives easier if this was included in some of the documentation somewhere, or an 'AWS' mode was added to the UI that just asks for the key or similar.

All 2 comments

Looking a the AWS AppSync docs for API_KEY, you pass the key in a header called x-api-key:

Using the 'Http Headers' section of GraphQL Playground, it appears it wants the headers as a JSON object:

{
  "x-api-key": "da2-FOOMYKEY"
}

This seemed to allow me to successfully query my API.

It would probably make peoples lives easier if this was included in some of the documentation somewhere, or an 'AWS' mode was added to the UI that just asks for the key or similar.

Awesome! That works for me, too. Thank you! 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  52Comments

heymartinadams picture heymartinadams  路  26Comments

Deepaknathtiwari picture Deepaknathtiwari  路  11Comments

alex996 picture alex996  路  15Comments

michalkvasnicak picture michalkvasnicak  路  14Comments