How to use graphql-playground-middleware-lambda - 6 common examples

To help you get started, we’ve selected a few graphql-playground-middleware-lambda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strvcom / dep-manager-web / src / lambda / playground.ts View on Github external
import playground from 'graphql-playground-middleware-lambda'
import { GITHUB_OAUTH_TOKEN, REACT_APP_GRAPHQL_ENDPOINT } from '../config/env'

const headers: { [key: string]: string } = {}

if (!REACT_APP_GRAPHQL_ENDPOINT) {
  throw new Error(`You must define REACT_APP_GRAPHQL_ENDPOINT env in order to GraphQL Playground`)
}

// fulfil headers for Playground requests. Not strictly required, can be
// altered through the Playground Settings UI.
if (GITHUB_OAUTH_TOKEN) {
  headers.authorization = `bearer ${GITHUB_OAUTH_TOKEN}`
}

const handle = playground({ endpoint: REACT_APP_GRAPHQL_ENDPOINT, headers })

/**
 * Simple wrapper to avoid duplicated response (callback + return).
 */
const handler: Handler = (lambdaEvent, context, callback) => {
  handle(lambdaEvent, context, callback)
}

export { handler }
github zotoio / serverless-central / packages / sample-graphql / src / handler.ts View on Github external
if (output) {
            output.headers['Access-Control-Allow-Origin'] = '*';
            log.info(output.body);
        } else {
            log.error(error);
        }

        callback(error, output);
    }

    const handler = graphqlLambda({ schema: myGraphQLSchema, tracing: true });
    return handler(event, context, callbackFilter);
};

// for local endpointURL is /graphql and for prod it is /stage/graphql
exports.playgroundHandler = lambdaPlayground({
    endpoint: process.env.REACT_APP_GRAPHQL_ENDPOINT ? process.env.REACT_APP_GRAPHQL_ENDPOINT : '/production/graphql'
});
github prisma-labs / graphql-playground / packages / graphql-playground-middleware-lambda / examples / basic / handler.js View on Github external
}

exports.graphqlHandler = function graphqlHandler(event, context, callback) {
  function callbackFilter(error, output) {
    // eslint-disable-next-line no-param-reassign
    output.headers['Access-Control-Allow-Origin'] = '*'
    callback(error, output)
  }

  const myGraphQLSchema = makeExecutableSchema({ typeDefs, resolvers })

  const handler = graphqlLambda({ schema: myGraphQLSchema })
  return handler(event, context, callbackFilter)
}

exports.playgroundHandler = lambdaPlayground({
   endpoint: '/dev',
})
github freeCodeCamp / open-api / src / handler.js View on Github external
try {
    JSON.parse(event.body);
  } catch (err) {
    const msg = 'Invalid JSON';
    log(msg, err);
    return callback(null, {
      body: msg,
      statusCode: 422
    });
  }

  return handler(event, context, callbackFilter);
};

exports.apiHandler = lambdaPlayground({
  endpoint: process.env.GRAPHQL_ENDPOINT_URL
    ? process.env.GRAPHQL_ENDPOINT_URL
    : '/production/graphql'
});
github Saeris / Flickr-Wormhole / src / index.js View on Github external
}

  const { statusCode, headers, result: body } = await server.inject({
    method,
    url,
    payload,
    headers: reqHeaders,
    validate: false
  })

  delete headers[`content-encoding`]
  delete headers[`transfer-encoding`]
  response(null, { statusCode, headers, body })
}

exports.playground = lambdaPlayground({
  endpoint: `/graphql`
})
github jgeschwendt / serverless-prisma / src / playground.ts View on Github external
import GraphQLPlayground from 'graphql-playground-middleware-lambda'
export const handler = GraphQLPlayground({ endpoint: '/' })

graphql-playground-middleware-lambda

GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular graphql-playground-middleware-lambda functions