How to use the graphql-server-express.graphqlExpress function in graphql-server-express

To help you get started, we’ve selected a few graphql-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 saikat / react-apollo-starter-kit / src / server / index.js View on Github external
// Parse bodies as JSON
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))

// In development, we use webpack server
if (process.env.NODE_ENV === 'production') {
  app.use(express.static(process.env.PUBLIC_DIR, {
    maxAge: '180 days'
  }))
}

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

app.use('/graphql', graphqlExpress({
  graphiql: true,
  pretty: true,
  schema,
  mocks,
  allowUndefinedInResolve: false
}))
// This middleware should be last. Return the React app only if no other route is hit.
app.use(appRenderer)
app.listen(port, () => {
  log.info(`Node app is running on port ${port}`)
})
github jfresco / graphql-workshop-es / ex / 05 / src / index.js View on Github external
const express = require('express')
const { graphqlExpress, graphiqlExpress } = require('graphql-server-express')
const bodyParser = require('body-parser')
const cors = require('cors')
const schema = require('./schema')

const app = express()

app.use('/graphql', cors(), bodyParser.json(), graphqlExpress({ schema }))

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

app.listen(3001, function () {
  console.log('Our Node server is up and running on port 3001!')
})
github nnance / swapi-apollo / src / express.ts View on Github external
export function startExpress(graphqlOptions) {
  app.use(bodyParser.json())
  app.use('/graphql', apollo.graphqlExpress(graphqlOptions))
  app.use('/', apollo.graphiqlExpress({endpointURL: '/graphql'}))

  app.listen(expressPort, () => {
      console.log(`Express server is listen on ${expressPort}`)
  })
}
github AEB-labs / graphql-weaver / spec / helpers / server / graphql-server.ts View on Github external
constructor(private readonly config: GraphQLServerConfig) {
        const app = express();
        app.use(cors());
        app.get('/', (req, res) => { res.redirect('/graphiql')});
        app.use('/graphql', bodyParser.json(), graphqlExpress(() => this.getGraphQLOptions()));
        app.use('/graphiql', graphiqlExpress({endpointURL: '/graphql'}));
        this.server = app.listen(config.port, () => {
            console.log(`GraphQL server started on http://localhost:${config.port}.`);
        });
    }
github scalable-react / scalable-react-typescript-boilerplate / src / server / graphqlEntry.ts View on Github external
return new Promise(async (res, rej) => {
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));
    app.use('/api', cors(), graphqlExpress({
      schema,
    }));

    app.use('/graphql-ui', graphiqlExpress({
      endpointURL: '/api',
    }));
    await createSchema().catch((err) => rej(err));
    res(app);
  });
};
github OasisDigital / angular-enterprise-example / servers / node / src / graphql / graphql.ts View on Github external
export function addGraphQL(server) {
  server.use('/graphql', bodyParser.json(),
    graphqlExpress({
      schema: jsSchema
    }));

  server.use('/graphiql', graphiqlExpress({
    endpointURL: '/graphql',
  }));
}
github JeffML / graphql-crud2 / src / server.js View on Github external
import express from 'express';
//import graphqlExpress from 'express-graphql';
import {
    graphqlExpress,
    graphiqlExpress
} from 'graphql-server-express';
import bodyParser from 'body-parser';

import schema from './schema';


const PORT = 3000;
const server = express();
const graphiql = true;

server.use('/graphql', bodyParser.json(), graphqlExpress(request => ({
    schema,
    //context: context(request.headers, process.env),
})));

server.use('/graphiql', graphiqlExpress({
    endpointURL: '/graphql',
    query: `# Welcome to GraphiQL

query PostsForAuthor {
  author(id: 1) {
    firstName
    lastName
    posts {
      id
      title
      votes
github AEB-labs / cruddl / spec / dev / graphql-server.ts View on Github external
constructor(private readonly config: GraphQLServerConfig) {
        const app = express();
        app.use(cors());
        app.get('/', (req, res) => { res.redirect('/graphiql')});
        app.use('/graphql', bodyParser.json(), graphqlExpress(() => this.getGraphQLOptions()));
        app.use('/graphiql', graphiqlExpress({endpointURL: '/graphql'}));
        this.server = app.listen(config.port, () => {
            logger.info(`GraphQL server started on http://localhost:${config.port}.`);
        });
    }
github olymp / olymp / packages / graphql / server / index.js View on Github external
export default (server, options) => {
  if (process.env.NODE_ENV !== 'production') {
    server.get('/graphql', graphiqlExpress({ endpointURL: '/graphql' }));
  }

  const { schema, getContext } = Schema.getSchema();
  server.post(
    '/graphql',
    graphqlExpress(request => ({ schema, context: getContext(request) }))
  );
};

graphql-server-express

Production-ready Node.js GraphQL server for Express and Connect

MIT
Latest version published 5 years ago

Package Health Score

59 / 100
Full package analysis