Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate fields in deep inputs not validated properly #1791

Closed
jbblanchet opened this issue Mar 14, 2019 · 1 comment
Closed

Duplicate fields in deep inputs not validated properly #1791

jbblanchet opened this issue Mar 14, 2019 · 1 comment
Labels

Comments

@jbblanchet
Copy link

When using a simple input, setting the same key twice will give an error: There can be only one input field named "y".

When using an input in an input, that second level input will not give the same error.

var { graphql, buildSchema } = require('graphql');

// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
  type Query {
    deepInput(input: InputA): String,
    singleInput(input: InputB): String
  }

  input InputA {
    x: InputB
  }

  input InputB {
    y: String
  }
`);

var root = {
  singleInput: () => {
    return 'Hello single world!';
  },
  deepInput: () => {
    return 'Hello deep world!';
  },
};

// This will five the error that `y` is defined twice
graphql(schema, '{ singleInput(input: { y: "foo", y: "bar" }) }', root).then((response) => {
  console.log(response);
}, (error) => {
  console.log(error)
});

// But this won't
graphql(schema, '{ deepInput(input: { x: { y: "foo", y: "bar" } }) }', root).then((response) => {
  console.log(response);
}, (error) => {
  console.log(error)
});
@IvanGoncharov
Copy link
Member

@jbblanchet Thanks for reporting 👍
Already fixed by @Cito in #1792 🚀 and will be included in the next release.

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

No branches or pull requests

2 participants