Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 2.19 KB

README.md

File metadata and controls

77 lines (52 loc) · 2.19 KB

appsync-cognito-query

Node.js CI Coverage Status

Package that makes easier the graphql requests to appsync when the authentication method is Cognito user pools

Getting Started

After installing the package, import the query manager as any package other package like this:

const acq = require('appsync-cognito-query');

Then we need to init the query manager and set the endpoint.

const manager = acq.init(YOUR_APPSYNC_ENDPOINT);

Then we can access the main functions of the manager. For a mutation query for example first we need to authenticate and then we can use graphql with the query method:

await manager.authenticateUser(YOUR_USER_POOL_ID, YOUR_CLIENT_ID, COGNITO_USER_USERNAME, COGNITO_USER_PASSWORD);

const mutation = `
        mutation CreateMessage {
          createMessage(input: {
            messageChatId:"5523456789",
            id: "12345",
            content:"Message content",
            createdAt: "2019-07-01T20:26:57.761Z",
            type: "TEXT"
          }) {
          id
          content
          type
          createdAt
      }
}`;

await manager.query(mutation);

Installing

This NPM package is installed such as any other one with the next command:

npm install appsync-cognito-query

Running the tests

npm run test

Built With

Contributing

I encourage and support the open source code so I will be very happy to receive contributions.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details