-
Notifications
You must be signed in to change notification settings - Fork 10
Type validation when using variables #2
Comments
Last line of the Documentation: "Note that this only validates literal values, variables are assumed to provide values of the correct type." While it is possible to check a literal value, I don't see a way to access variable values during validation. Seems to be a limitation of this method. If you really need it, the only option I see is to somehow manually insert a variable into the query string on the server before calling |
Perhaps I'm misunderstanding, but couldn't you do this in |
Hi Cardinal90, I managed to get this going in parseValue as taion mentioned. I'm not sure if the way I did it was particularly correct, but I did it like this: parseValue: function(value) {
var inputType, ast;
if (typeKey && value[typeKey]) {
inputType = referenceTypes[value[typeKey]];
}
ast = astFromValue(value, inputType);
return valueFromAST(ast, inputType);
}, Obviously this requires you to only use the typeKey method, but I assume it could be made to work with the other techniques as well? |
Hello. Sorry for not replying for some time. On another note, graphql-js 0.10.1 broke my tests. I reported this here. It shouldn't cause any real problems, at least if your inputs don't have mistakes in them. |
Hello,
When using variables in query, the inputType never get validated.
Assuming we're using your Star Wars schema, the following will work, whatever the
side
input in variables :The text was updated successfully, but these errors were encountered: