How to use hops-apollo-mock-server - 1 common examples

To help you get started, we’ve selected a few hops-apollo-mock-server 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 xing / hops / packages / apollo-mock-server / lib / mock-server-middleware.js View on Github external
import { ApolloServer } from 'apollo-server-express';
import cookieParser from 'cookie-parser';
import express from 'express';
import hopsConfig from 'hops-config';
// eslint-disable-next-line node/no-extraneous-import
import schema from 'hops-apollo-mock-server/schema';
// eslint-disable-next-line node/no-extraneous-import
import extendContext from 'hops-apollo-mock-server/context-extender';

const apolloAppPromise = Promise.resolve(
  typeof schema === 'function' ? schema() : schema
).then(resolvedSchema => {
  const app = express();
  app.use(cookieParser());

  const server = new ApolloServer({
    schema: resolvedSchema,
    playground: {
      settings: {
        'request.credentials': 'same-origin',
      },
    },
    context: context => extendContext({ ...context, config: hopsConfig }),
  });

  server.applyMiddleware({
    app,

hops-apollo-mock-server

Apollo based mock server for Hops

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis

Popular hops-apollo-mock-server functions