Skip to content

Updated graphql-from-node examples to be amplify mock compatible #4441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 23, 2023
10 changes: 6 additions & 4 deletions src/fragments/lib/graphqlapi/graphql-from-node.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
You can call an AppSync GraphQL API from a Node.js app or a Lambda function. Take a basic `Todo` app as an example:

```graphql
type Todo @model @auth(rules: [{ allow: public }]) {
name: String
Expand Down Expand Up @@ -112,9 +112,10 @@ export const handler = async (event) => {
const options = {
method: 'POST',
headers: {
'x-api-key': GRAPHQL_API_KEY
'x-api-key': GRAPHQL_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ query, variables })
body: JSON.stringify({ query })
};

const request = new Request(GRAPHQL_ENDPOINT, options);
Expand Down Expand Up @@ -184,7 +185,8 @@ export const handler = async (event) => {
const options = {
method: 'POST',
headers: {
'x-api-key': GRAPHQL_API_KEY
'x-api-key': GRAPHQL_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ query, variables })
};
Expand Down