graphql-faker: Cannot extend Mutation

Hi! We’ve been struggling with this for quite a while now, so thought I’d try and ask for help.

Our use-case is simple. Extend an existing schema, and implement new Mutations and Queries. While extending the original Query type works perfectly fine for us, as soon as we try extending the original Mutation type, we get strange errors, possibly related to how the merge is being done and the resulting AST parsed / constructed. Please note we only get this result when using variables; sending hard-coded values works just fine.

We have done some investigation and it appears that the culprit is this method https://github.com/APIs-guru/graphql-faker/blob/master/src/proxy.ts#L122. Unfortunately, this is where we run out of depth, as we currently don’t have the bandwidth to study the visit method / API properly.

If anyone here has enough insight on this, it would be awesome if you could help us out. Any input and / or advice is greatly appreciated 😃

Our “extend”

type Car {
  id: String @fake(type: uuid)
  ownerName: String @fake(type: fullName)
}

input NewCarInput {
  ownerName: String!
}

extend type Mutation {
  createCar(input: NewCarInput!): Car!
}

Our mutation

mutation CreateCar($input: NewCarInput!) {
  createCar(input: $input) {
    id
  }
}

Result

{
  "errors": [
    {
      "message": "400 Bad Request\n{\"errors\":[{\"message\":\"Unknown type \\\"NewCarInput\\\". Did you mean ... ?\",\"locations\":[{\"line\":1,\"column\":28}]},{\"message\":\"Variable \\\"$input\\\" is never used in operation \\\"CreateCar\\\".\",\"locations\":[{\"line\":1,\"column\":20}]}]}"
    }
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@codenakama Thanks for reporting this issue 👍 Fixed in 2.0.0-rc.5 🎉 Can you please test it?

@slavovojacek Great! Tests will be great especially some snapshot testing will be great.

My main goal at the moment is to stop using custom forks of graphql-js and express-graphql. So I’m working on pushing necessary functionality into mainlines testing is my second priority after that.