Disable auto generated mutation with Neo4jGraphQL

Greetings, I'm currently in the process of developing a Grand Stack Web Application. In my pursuit, I'm seeking a method to deactivate the automated generation of mutations. In the past, this could be accomplished through the now-deprecated neo4j-graphql-js library, as discussed in this link: How to disable generated mutations? · Issue #117 · neo4j-graphql/neo4j-graphql-js · GitHub.

Despite my attempts, I've encountered an obstacle when trying to achieve this using the new framework. I've experimented with passing a configuration option where the 'mutation' parameter is set to 'false', but unfortunately, this approach didn't yield the desired outcome. Below is a snippet of the relevant code I've been working with:

javascript

import errorMiddleware from "./src/middlewares/error.middleware.js";
import { Neo4jGraphQL } from "@neo4j/graphql";
import express from "express";
import * as neo4j from "./src/databases/neo4j.database.js";
import bodyParser from "body-parser";
import * as env from "./properties.js";
import cors from "cors";
import { expressMiddleware } from "@apollo/server/express4";
import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
import http from "http";
import { ApolloServer } from "@apollo/server";
import { observationResolvers } from "./src/graphql/resolvers.js";
import { observationTypedefs } from "./src/graphql/typedefs.js";

var app = express();

const driver = neo4j.initDriver("bolt://localhost:7687", "neo4j", "password");
const httpServer = http.createServer(app);

const neoSchema = new Neo4jGraphQL({
  driver: driver,
  typeDefs: observationTypedefs,
  resolvers: observationResolvers,
  config: {
    mutation: false
  }
});

const server = new ApolloServer({
  schema: await neoSchema.getSchema(),
  plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
});

await server.start();

app.use("/observations", cors(), bodyParser.json(), expressMiddleware(server));
await new Promise((resolve) => httpServer.listen({ port: 8087 }, resolve));
console.log(`🚀 Server ready at http://localhost:8087 🚀`);

I would greatly appreciate any insights or guidance you might have on how to address this issue effectively. If this is possible, can specific queries be disabled? In particular the ones that are maanged by custom resolvers?

Hello cxnturi0n!

There are several different ways you can configure your schema, so there's a section in the documentation dedicated to that:

To globally disable mutations, this can be added to the type definitions:

extend schema @mutation(operations: [])

Or for example, if they only wanted to allow update mutations:

extend schema @mutation(operations: [UPDATE])

More details specifically for the @mutation directive: Type configuration - Neo4j GraphQL Library