Skip to content
On this page

Adding Graphql

To add graphql to a remult application follow these steps:

  1. Install the graphql and express-graphql packages:
    npm i graphql express-graphql
  2. In the /src/server/index.ts file add the following code:
    import express from 'express';
    import { buildSchema } from 'graphql';
    import { graphqlHTTP } from 'express-graphql';
    import { remultGraphql } from 'remult/graphql';
    import { remultExpress } from 'remult/remult-express';
    const app = express();
    let api = remultExpress();
    const { schema, rootValue } = remultGraphql(api);
    app.use('/api/graphql', graphqlHTTP({
        schema: buildSchema(schema),
        graphiql: true,
    app.listen(3002, () => console.log("Server started"));

MIT Licensed | Made by the Remult team with ❤️