How to use the apollo-server-express.graphiqlExpress function in apollo-server-express

To help you get started, we’ve selected a few apollo-server-express 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 reactioncommerce / reaction / server / graphql / server.js View on Github external
// something went bad when configuring the graphql server, we do not
        // swallow the error and display it in the server-side logs
        Logger.error(error, "[GraphQL Server] Something bad happened when handling a request on the GraphQL server");

        // return the default graphql options anyway
        return defaultGraphQLOptions;
      }
    })
  );

  // Start GraphiQL if enabled
  if (config.graphiql) {
    // GraphiQL endpoint
    expressServer.use(
      config.graphiqlPath,
      graphiqlExpress({
        // GraphiQL options
        ...config.graphiqlOptions,
        // endpoint of the graphql server where to send requests
        endpointURL: config.path
      })
    );
  }

  // bind the specified paths to the Express server running Apollo + GraphiQL
  WebApp.connectHandlers.use(expressServer);
}
github loic-carbonne / realtime-notifications-apollo-graphql / backend / index.js View on Github external
return newNotification;
      },
  },
  Subscription: {
    newNotification: {
      subscribe: () => pubsub.asyncIterator(NOTIFICATION_SUBSCRIPTION_TOPIC)
    }
  },
};
const schema = makeExecutableSchema({ typeDefs, resolvers });

const app = express();
app.use('*', cors({ origin: `http://localhost:3000` }));
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
app.use('/graphiql', graphiqlExpress({
  endpointURL: '/graphql',
  subscriptionsEndpoint: `ws://localhost:4000/subscriptions`
}));
const ws = createServer(app);
ws.listen(4000, () => {
  console.log('Go to http://localhost:4000/graphiql to run queries!');

  new SubscriptionServer({
    execute,
    subscribe,
    schema
  }, {
    server: ws,
    path: '/subscriptions',
  });
});
github serverless / serverless-graphql / foundation / app-server / server.js View on Github external
const PORT = 4000;
const graphQLServer = express();

console.log(process.env.CLIENT_URL);

const client = process.env.CLIENT_URL;
graphQLServer.use('*', cors({ origin: client }));

const myGraphQLSchema = makeExecutableSchema({
  typeDefs: schema,
  resolvers,
  logger: console,
});

graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema: myGraphQLSchema }));
graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));

graphQLServer.listen(PORT, () =>
    console.log(`GraphQL Server is now running on http://localhost:${PORT}`),
);
github benjaminadk / youtube-clone / server.js View on Github external
schema,
    context: {
      models,
      user: req.user
    }
  }))
)

const subscriptionsEndpoint =
  process.env.NODE_ENV === 'production'
    ? `wss://fake-youtube.herokuapp.com/subscriptions`
    : `ws://localhost:${PORT}/subscriptions`

server.use(
  '/graphiql',
  graphiqlExpress({
    endpointURL: '/graphql',
    subscriptionsEndpoint
  })
)

if (process.env.NODE_ENV === 'production') {
  server.use(express.static('client/build'))
  server.get('*', (req, res) => {
    res.sendFile(path.resolve('client', 'build', 'index.html'))
  })
}

const ws = createServer(server)
ws.listen(PORT, () => {
  console.log(`APOLLO SERVER UP`)
  new SubscriptionServer(
github MainframeHQ / onyx / packages / onyx-server / src / graphql / server.js View on Github external
export default (
  pss: PssAPI,
  db: DB,
  port: number,
  app: express$Application,
) => {
  const schema = createSchema(pss, db, port)
  const log = debug('onyx:graphql')

  app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }))
  app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }))

  return {
    schema,
    onCreated: (server: net$Server) => {
      SubscriptionServer.create(
        {
          execute,
          schema,
          subscribe,
        },
        { path: '/graphql', server },
      )
    },
  }
}
github mrdulin / apollo-server-express-starter / src / subscription / demo-3 / app.ts View on Github external
app.use(
    config.GRAPHQL_ROUTE,
    bodyParser.json(),
    graphqlExpress((req: any) => {
      return {
        schema,
        context: {
          db: lowdb,
          user: req.user
        }
      };
    })
  );
  app.use(
    config.GRAPHIQL_ROUTE,
    graphiqlExpress({ endpointURL: config.GRAPHQL_ROUTE, subscriptionsEndpoint: config.WEBSOCKET_ENDPOINT })
  );
}
github mrdulin / apollo-server-express-starter / src / subscription / demo-1 / server.ts View on Github external
app.use(cors(), auth);
  app.use(
    config.GRAPHQL_ROUTE,
    bodyParser.json(),
    graphqlExpress((req?: express.Request) => {
      return {
        schema,
        context: {
          user: (req as any).user
        }
      };
    })
  );
  app.use(
    config.GRAPHIQL_ROUTE,
    graphiqlExpress({ endpointURL: config.GRAPHQL_ROUTE, subscriptionsEndpoint: config.WEBSOCKET_ENDPOINT })
  );
}
github artsmia / lume / server / src / index.js View on Github external
server.set('port', port)

server.use(
  cors(),
  bodyParser.json(),
  authMiddleware,
)


server.use('/mia/:type', miaEndpoints)


server.use("/image", upload.single("file") , imageRoute)


server.use('/graphiql', graphiqlExpress({
  endpointURL: '/'
}))

server.use('/iiif/:identifier/info.json', info)

server.use('/iiif/:identifier/:region/:size/:rotation/:quality.:format', iiif)

server.use('/', graphqlExpress((req, res) => {
  return {
    schema,
    context: req
  }
}))