Skip to content

Fix the error message for unknown field #261

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

Merged
merged 1 commit into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/execution/__tests__/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ describe('Execute: Handles inputs', () => {
});

it('errors on addition of unknown input field', async () => {
var params = { input: { a: 'foo', b: 'bar', c: 'baz', d: 'dog' } };
var params = { input: { a: 'foo', b: 'bar', c: 'baz', extra: 'dog' } };

var caughtError;
try {
Expand All @@ -330,9 +330,8 @@ describe('Execute: Handles inputs', () => {
locations: [ { line: 2, column: 17 } ],
message:
'Variable "$input" got invalid value ' +
'{"a":"foo","b":"bar","c":"baz","d":"dog"}.' +
'\nIn field "d": Expected type "ComplexScalar", found "dog".'

'{"a":"foo","b":"bar","c":"baz","extra":"dog"}.' +
'\nIn field \"extra\": Unknown field.'
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/isValidJSValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function isValidJSValue(value: any, type: GraphQLInputType): [ string ] {
// Ensure every provided field is defined.
for (var providedField of Object.keys(value)) {
if (!fields[providedField]) {
errors.push('In field "${providedField}": Unknown field.');
errors.push(`In field "${providedField}": Unknown field.`);
}
}

Expand Down