Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

How to disable generated mutations? #117

Closed
jameslouiz opened this issue Oct 2, 2018 · 2 comments
Closed

How to disable generated mutations? #117

jameslouiz opened this issue Oct 2, 2018 · 2 comments

Comments

@jameslouiz
Copy link

Hi, how do I disable the generated mutations?

@jameslouiz jameslouiz changed the title Disabled generated mutations Disable generated mutations Oct 2, 2018
@jameslouiz jameslouiz changed the title Disable generated mutations How to disable generated mutations? Oct 2, 2018
@behemothdan
Copy link

behemothdan commented Oct 4, 2018

According to the documentation, you can call neo4jgraphql in your GraphQL resolver.

import { neo4jgraphql } from 'neo4j-graphql-js';

const resolvers = {
  Query: {
    Movie(object, params, ctx, resolveInfo) {
      return neo4jgraphql(object, params, ctx, resolveInfo);
    },
  Mutation: {
    CreateMovie(object, params, ctx, resolveInfo) {
      return neo4jgraphql(object, params, ctx, resolveInfo);
    }
  }
};

If you are using ApolloServer or the GRAND stack starter, you'll want leave out/comment out where the augmentedSchema is being called (usually where you instantiate your ApolloServer). It will look something like this:

const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: { driver },
});

@johnymontana
Copy link
Contributor

augmentSchema and makeAugmentedSchema now take an optional config parameter that can be used to specify generated mutations and queries.

To disable all generated mutations (but still generate queries):

import { makeAugmentedSchema } from "neo4j-graphql-js";

const schema = makeAugmentedSchema({ 
  typeDefs,
  config: {
    mutation: false
  }
}

You could also specify types to be excluded from either the generated queries or mutations:

import { makeAugmentedSchema } from "neo4j-graphql-js";

const schema = makeAugmentedSchema({
  typeDefs,
  config: {
    query: {
      exclude: ["MyCustomPayload"]
    },
    mutation: {
      exclude: ["MyCustomPayload"]
    }
  }
});

See more examples in the docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants