How to use the graphql-playground-middleware-lambda function in graphql-playground-middleware-lambda

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 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 3 years ago

Package Health Score

62 / 100
Full package analysis

Popular graphql-playground-middleware-lambda functions