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

To help you get started, we’ve selected a few apollo-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 jangerhofer / apolloFileUpload / server / main.js View on Github external
let graphQLServer = express();

// Configure multer to accept a single file per post
const storage = multer.memoryStorage();
graphQLServer.use(multer({
  storage,
}).single('file'));

graphQLServer.use('/graphql', bodyParser.json(), apolloExpress((req) => ({
  schema,
  rootValue: req,
})
));

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

WebApp.connectHandlers.use(Meteor.bindEnvironment(graphQLServer));
github react-native-training / apollo-graphql-mongodb-react-native / apolloserver / app.js View on Github external
const Connectors = require('./connectors');

const executableSchema = makeExecutableSchema({
  typeDefs: Schema,
  resolvers: Resolvers,
});

app.use('/graphql', bodyParser.json(), apolloExpress({
  schema: executableSchema,
  context: {
    constructor: Connectors,
  },
  rootValue: 'Hello World',
}));

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

app.listen(PORT, () => console.log(
  `GraphQL Server is now running on http://localhost:${PORT}/graphql`
));
github feats / perfect-graphql-starter / server / index.js View on Github external
const PORT = 8080;
const app = express();

app.use('/graphql', bodyParser.json(), apolloExpress({
  schema,
  resolvers,
  context: {},
  formatError(error) {
    console.error(error.stack);
    return error;
  },
}));

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

app.listen(PORT, () => console.log(
  `GraphQL Server is now running on http://localhost:${PORT}/graphiql`
));

process.on('exit', () => {
  console.log('Shutting down!');

  for (const connector of Object.values(connectors)) {
    connector.close();
  }
});
github rricard / movieql / data / server.js View on Github external
},
    formatError: (error: Error) => {
      console.error('GraphQL execution error:', error.stack);
      return error.message;
    },
    formatResponse: (data: any) => {
      console.info('✅ Outgoing GraphQL Response');
      console.info('----------------------------');
      console.info(JSON.stringify(data, null, ' '));
      console.info('');
      console.info('');
      return data;
    }
  }));
  
  app.use('/graphiql', graphiqlExpress({
    endpointURL: '/graphql',
  }));

  app.listen(PORT, () => console.info(`
    🎉 GraphQL endpoint available at http://${HOST}:${PORT}/graphql
    GraphiQL IDE available at http://${HOST}:${PORT}/graphiql
  `));
});
github graphitejs / server / packages / graphite-apollo-express / src / graphql / graphQLServer.js View on Github external
try {
      this.executableSchema = makeExecutableSchema({
        typeDefs: typeDefs(Types, Query, Mutation),
        resolvers: Resolvers,
        logger: { log: this.customLogger.bind(this) },
      });
    } catch (err) {
      this.logger(err);
    }
    collections.filter(this.hasPropertyInitialize.bind(this))
               .forEach(this.executeInitialize.bind(this));

    const apollo = apolloExpress(this.requestApolloExpress.bind(this));
    this.Graphite.use('/graphql', cors(), bodyParser.json(), apollo);
    this.Graphite.use('/graphiql', bodyParser.json(), graphiqlExpress({
      endpointURL: '/graphql',
    }));

    this.Graphite.listen(GRAPHQL_PORT, this.listenGraphQl.bind(this, GRAPHQL_PORT));
    this.Graphite.getSchema = () => getSchema(`http://localhost:${GRAPHQL_PORT}/graphql`);
    return this.Graphite;
  }