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

Prevent auto generation of update, create, ... methods #128

Closed
benpetsch opened this issue Oct 10, 2018 · 3 comments
Closed

Prevent auto generation of update, create, ... methods #128

benpetsch opened this issue Oct 10, 2018 · 3 comments

Comments

@benpetsch
Copy link

Context/Problem:
I'm facing an issue with auto generated update & creat method for an input type.
The input type "AuthPayload" returns an user object + auth token.
this type "AuthPayload" will never be updated or created nor read by any graphql client. It lives only as payload, therefore no auto generated methods from neo4j-graphql-js.

Question:
Is there a way to prevent neo4j-graphql-js from generating update,create resolvers for a type.
Maybe something like this:

@IGNORE
type AuthPayload {
  user: User!
  token: String!
}

subset of my schema.graphql

type Mutation {
  login(data: LoginUserInput!): AuthPayload!
}

input LoginUserInput {
  email: String!
  password: String!
}

type AuthPayload {
  user: User!
  token: String!
}

error response within graphql gui:

{
  "error": {
    "errors": [
      {
        "message": "The type of Mutation.UpdateAuthPayload(user:) must be Input Type but got: User!.\n\nThe type of Mutation.DeleteAuthPayload(user:) must be Input Type but got: User!.\n\nThe type of _AuthPayloadInput.user must be Input Type but got: User!.",
        "extensions": {
          "code": "GRAPHQL_VALIDATION_FAILED",
          "exception": {
            "stacktrace": [
              "Error: The type of Mutation.UpdateAuthPayload(user:) must be Input Type but got: User!.",
              "",
              "The type of Mutation.DeleteAuthPayload(user:) must be Input Type but got: User!.",
@johnymontana
Copy link
Contributor

Hi @benpetsch - not currently, but @michaeldgraham is currently working on a feature that will add support for this.

It will not be directive based, but instead an optional configuration object will be passed to makeAugmentedSchema or augmentSchema specificying which types should have auto-generated queries and mutations.

@benpetsch
Copy link
Author

@johnymontana thanks for the fast support. Do you know the "estimated time of arrival" for that feature?

@johnymontana
Copy link
Contributor

@benpetsch we've now added an optional config parameter for augmentSchema and makeAugmentedSchema that can be used to specify generated mutations and queries.

To exclude specific types from the schema augmentation process:

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

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

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

2 participants