How to use graphql-playground-middleware-koa - 10 common examples

To help you get started, we’ve selected a few graphql-playground-middleware-koa 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 gsasouza / house-automation / packages / server / src / app.ts View on Github external
import schema from './schema/schema';
import { authenticatedMiddleware } from './auth';
import { dataloadersMiddleware } from './loaders/dataloadersMiddleware';

const app = new Koa();
const router = new Router();

app.context.pubnub = pubNubSetup();


// app.use(morgan('tiny'))
app.use(dataloadersMiddleware)
app.use(authenticatedMiddleware)
router.get('/', ctx => ctx.body = 'Hello World')

router.all('/playground', koaPlayground({
  endpoint: '/graphql',
  subscriptionEndpoint: `ws://localhost:${SERVER_PORT}/subscriptions`,
}))

router.all('/graphql', graphqlHTTP({
  schema,
  graphiql: true
}))

app.use(cors());
app.use(router.routes()).use(router.allowedMethods());

export default app;
github ojkelly / bunjil / src / bunjil.ts View on Github external
tracing: true,
            }),
        );

        // Optionally add the playground
        if (
            this.playgroundOptions.enabled &&
            typeof this.endpoints.playground === "string"
        ) {
            const playgroundOptions: playgroundOptions = {
                ...this.playgroundOptions,
                endpoint: this.endpoints.graphQL,
            };
            this.router.get(
                this.endpoints.playground,
                KoaPlaygroundMiddleware(playgroundOptions),
            );
        }
    }
github entria / entria-fullstack / packages / server / src / app.ts View on Github external
message: error.message,
        locations: error.locations,
        stack: error.stack,
      };
    },
  };
};

const graphqlServer = graphqlHttp(graphqlSettingsPerReq);

// graphql batch query route
router.all('/graphql/batch', bodyParser(), graphqlBatchHttpWrapper(graphqlServer));
router.all('/graphql', graphqlServer);
router.all(
  '/graphiql',
  koaPlayground({
    endpoint: '/graphql',
    subscriptionEndpoint: '/subscriptions',
  }),
);

app.use(logger());
app.use(cors());
app.use(router.routes()).use(router.allowedMethods());

export default app;
github the-control-group / authx / packages / authx / src / index.ts View on Github external
? config.processSchema(createSchema(strategies))
          : createSchema(strategies),
        override: (ctx: any) => {
          const contextValue: Context = ctx[x];

          return {
            contextValue
          };
        }
      })
    );

    // GraphiQL
    // ========
    // This is a graphical (get it, graph-i-QL) interface to the AuthX API.
    this.all("/graphiql", createPlaygroundMiddleware({ endpoint: "/graphql" }));

    // OAuth
    // =====
    // The core AuthX library supports the following OAuth2 grant types:
    //
    // - `authorization_code`
    // - `refresh_token`
    //
    // Because it involves presentation elements, the core AuthX library does
    // **not** implement the `code` grant type. Instead, a compatible reference
    // implementation of this flow is provided by the `authx-interface` NPM
    // package.

    this.post(
      "/",
      contextMiddleware as AuthXMiddleware,
github Bastiani / bastiani-blog / server / index.ts View on Github external
// router.get('/admin', async ctx => {
  //   await handle(ctx.req, ctx.res);
  //   ctx.respond = false;
  // });

  router.get('/signin', async ctx => {
    await handle(ctx.req, ctx.res);
    ctx.respond = false;
  });

  router.all('/graphql', graphqlServer);

  if (process.env.NODE_ENV !== 'production') {
    router.all(
      '/playground',
      koaPlayground({
        endpoint: '/graphql'
      })
    );
  }

  router.get('*', async ctx => {
    await handle(ctx.req, ctx.res);
    ctx.respond = false;
  });

  server.use(async (ctx, next) => {
    ctx.res.statusCode = 200;
    await next();
  });

  server.use(cors());
github entria / graphql-dataloader-boilerplate / src / app.ts View on Github external
message: error.message,
        locations: error.locations,
        stack: error.stack,
      };
    },
  };
};

const graphqlServer = graphqlHttp(graphqlSettingsPerReq);

// graphql batch query route
router.all('/graphql/batch', bodyParser(), graphqlBatchHttpWrapper(graphqlServer));
router.all('/graphql', graphqlServer);
router.all(
  '/graphiql',
  koaPlayground({
    endpoint: '/graphql',
    subscriptionEndpoint: `ws://localhost:${process.env.GRAPHQL_PORT}/subscriptions`,
  }),
);

app.use(logger());
app.use(cors());
app.use(router.routes()).use(router.allowedMethods());

export default app;
github ctco / nodejs-graphql-template / src / app.ts View on Github external
}));
}

// GraphiQL?
if (process.env.GRAPHIQL) {
  router.get(
    `/${paths.GRAPHIQL_PATH}`,
    graphiqlKoa({ endpointURL: GRAPHQL_ENDPOINT }),
  );
}

// GraphQL Playground?
if (process.env.PLAYGROUND) {
  router.all(
    `/${paths.PLAYGROUND_PATH}`,
    koaPlayground({ endpoint: GRAPHQL_ENDPOINT }),
  );
}

// Koa Heartbeat
app.use(koaHeartbeat({ path: `/${paths.LIVENESS_PATH}`, body: 'ok' }));

app.use(router.routes());
app.use(router.allowedMethods());

export default app;
github renanmav / relayable / packages / server / src / app.ts View on Github external
res,
      dataloaders,
      user,
      pubSub
    }
  }
  return options
}

const graphqlServer = graphqlHttp(graphqlSettingsPerReq)

router.all('/graphql', bodyParser(), graphqlServer)
if (process.env.NODE_ENV !== 'production') {
  router.all(
    '/graphiql',
    koaPlayground({
      endpoint: '/graphql',
      subscriptionEndpoint: '/subscriptions'
    })
  )
}

app.use(logger())
app.use(cors())
app.use(router.routes()).use(router.allowedMethods())

export default app
github sid88in / serverless-appsync-plugin / graphql-playground.js View on Github external
]).then(([headers, endpoint]) => {
    const app = new Koa();
    app.use(koaPlayground({
      endpoint,
      settings: {
        'editor.cursorShape': 'line',
        'editor.reuseHeaders': true,
      },
      tabs: [{
        endpoint,
        headers,
      }],
    }));

    const port = options.port || 3000;
    app.listen(port);
    const graphiqlUrl = `http://localhost:${port}`;

    return graphiqlUrl;

graphql-playground-middleware-koa

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

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular graphql-playground-middleware-koa functions