Skip to content
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