Skip to content

Just make GraphQL requests through AWS LambdaInvoke or HTTP

License

Notifications You must be signed in to change notification settings

nutshell-lab/aws-apollo-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aws Apollo Tools

Node version

Table of Contents

Prerequisites

in serverless.yml

...
provider:
  ...
  environment:
    SLS_STAGE: ${self:provider.stage} 
  iamRoleStatements:
    - Effect: Allow
      Action:
        - execute-api:*
      Resource: '*'
...

Getting Started

  • Run yarn add @nutshelllab/aws-apollo-tools
  • import * from '@nutshelllab/aws-apollo-tools'

Usage

LambdaRequest

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
variables false object
headers false object

HttpRequest

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
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

About

Just make GraphQL requests through AWS LambdaInvoke or HTTP

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published