https://github.com/nutshell-lab/aws-apollo-tools
Just make GraphQL requests through AWS LambdaInvoke or HTTP
https://github.com/nutshell-lab/aws-apollo-tools
aws graphql httprequest lambda nodejs
Last synced: about 1 month ago
JSON representation
Just make GraphQL requests through AWS LambdaInvoke or HTTP
- Host: GitHub
- URL: https://github.com/nutshell-lab/aws-apollo-tools
- Owner: nutshell-lab
- License: mit
- Created: 2018-11-26T13:17:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T07:38:40.000Z (over 3 years ago)
- Last Synced: 2025-09-23T22:30:55.340Z (9 months ago)
- Topics: aws, graphql, httprequest, lambda, nodejs
- Language: JavaScript
- Homepage:
- Size: 2.47 MB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-apollo-tools [](https://nodejs.org/en/blog/release/v8.10.0/)
> Just make GraphQL requests through AWS LambdaInvoke or HTTP
## Install
```
$ yarn add @nutshelllab/aws-apollo-tools
```
## Usage
### Prerequisites
in `serverless.yml`
```yml
...
provider:
...
environment:
SLS_STAGE: ${self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action: # Set permissions for specific Lambdas
- execute-api:*
Resource: '*'
...
```
### LambdaRequest
```js
import gql from 'graphql-tag'
import graphqlLambdaRequest from '@nutshelllab/aws-apollo-tools/lambda-request'
const request = gql`
query getItem($id: ID!) {
getItem(id: $id) {
id
}
}
`
const variables = {
id: '110e8400-e29b-11d4-a716-446655440000'
}
const test = await graphqlLambdaRequest({
lambdaName: 'my-lambda-name',
region: 'eu-west-1',
request,
variables
})
```
#### Options
|name|required|type|info|
|---|---|---|---|
|lambdaName|true|string|The lambda endpoint must provide an apollo server|
|region|true|string| |
|request|true|string|It must be a GraphQL query [graphql-tag](https://github.com/apollographql/graphql-tag#readme)|
|variables|false|object| |
|headers|false|object| |
### HttpRequest
```js
import gql from 'graphql-tag'
import graphqlHttpRequest from '@nutshelllab/aws-apollo-tools/http-request'
const request = gql`
query getItem($id: ID!) {
getItem(id: $id) {
id
}
}
`
const variables = {
id: '110e8400-e29b-11d4-a716-446655440000'
}
const test = await graphqlHttpRequest({
uri: 'https://my-apollo-server-endpoint.com',
region: 'eu-west-1',
request,
variables,
signed: true
})
```
#### Options
|name|required|type|info|
|---|---|---|---|
|uri|true|string|The http endpoint must provide an apollo server|
|region|true|string| |
|request|true|string|It must be a GraphQL query [graphql-tag](https://github.com/apollographql/graphql-tag#readme)|
|signed|false|bool|Setting to `true` enable aws signature v4, be sure that your http endpoint as `authorizer: aws_iam`|
|variables|false|object| |
|headers|false|object| |
## License
MIT © [Nutshell](https://nutshell-lab.com)