1.0.11 • Published 5 years ago

@nutshelllab/aws-apollo-tools v1.0.11

Weekly downloads
1
License
GNU GENERAL PUBLI...
Repository
github
Last release
5 years ago

aws-apollo-tools Node version

Just make GraphQL requests through AWS LambdaInvoke or HTTP

Install

$ yarn add @nutshelllab/aws-apollo-tools

Usage

Prerequisites

in serverless.yml

...
provider:
  ...
  environment:
    SLS_STAGE: ${self:provider.stage} 
  iamRoleStatements:
    - Effect: Allow
      Action: # Set permissions for specific Lambdas
        - execute-api:*
      Resource: '*'
...

LambdaRequest

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

namerequiredtypeinfo
lambdaNametruestringThe lambda endpoint must provide an apollo server
regiontruestring
requesttruestringIt must be a GraphQL query graphql-tag
variablesfalseobject
headersfalseobject

HttpRequest

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

namerequiredtypeinfo
uritruestringThe http endpoint must provide an apollo server
regiontruestring
requesttruestringIt must be a GraphQL query graphql-tag
signedfalseboolSetting to true enable aws signature v4, be sure that your http endpoint as authorizer: aws_iam
variablesfalseobject
headersfalseobject

License

MIT © Nutshell

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago