bug: AppSync only accepts POST requests
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
AppSync API only accept GraphQL queries as POST requests despite AWS also allowing them passed in via GET.
Expected Behavior
The queries can be passed in via POST or GET.
How are you starting LocalStack?
With the localstack script
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)
localstack start
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
Save the following minimal schema in the file minimal.graphql
type Entity {
id: String!
}
type Query {
getEntity(id: String!): Entity
}
Then run
awslocal appsync create-graphql-api --name entities --authentication-type API_KEY
awslocal appsync start-schema-creation --api-id <API ID> --definition $(base64 < minimal.graphql)
Save the following example resolver in the file getEntity-resolver.js
import { util } from '@aws-appsync/utils';
import { get } from '@aws-appsync/utils/dynamodb';
export function request(ctx) {
const { id } = ctx.arguments;
const key = { id };
return get({
key,
})
}
export function response(ctx) {
const { error, result } = ctx;
if (error) {
return util.appendError(error.message, error.type, result);
}
return result;
}
And then run
awslocal appsync create-resolver --api-id <API ID> --type-name Query --field-name getEntity --runtime name=APPSYNC_JS,runtimeVersion=1.0.0 --code "$(cat getEntity-resolver.js)"
awslocal appsync create-api-key --api-id <API ID>
Now save the query in the file minimal-query.json
{
"query": "query {
getEntity(id: \"1\") {
id
}
}"
}
And call the API using the URL and API key
curl -v -H "x-api-key: <API key>" -H "Content-Type: application/json" -d @minimal-query.json <URL>
Note that you're getting the correct response {"data": {"getEntity": null}}.
Now run the same query as a GET request
curl -v -g -H "x-api-key: <API key>" <URL>"?query={getEntity(id:\"1\"){id}}"
and you receive
{"__type": "InternalError", "message": "exception while calling appsync with unknown operation: 400 Bad Request: Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"}
Environment
- OS: MacOs
- LocalStack: 3.1.1.dev
Anything else?
No response
any movement on this ?
Hello 👋! It looks like this issue hasn’t been active in longer than five months. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
Thank you @johannesfloriangeiger for reporting the issue.
I appreciate your patience and I am happy to announce that submitting queries to the appsync api endpoint now accepts GET queries and reading queries from the query parameters.
Could you please run docker pull localstack/localstack-pro:latest and see if that would solve your issue? Thank you!
Hello 👋! It looks like this issue hasn’t been active in longer than two weeks. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.