-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Rework] Input argument validation #2994
Comments
The other thing on my mind is, the reason for that previous PR (IIUC) is because Shopify expects
Did I understand that issue previously? How do y'all want to go forward with it? |
That's a great summary, thanks Robert. We're chatting internally but we're coming around to the idea that the logging we want should ultimately be decoupled from Related to that: there's a weaker/inverse expectation we're using that |
EDIT: The problem was on my side, but didn't find it in time to remove this message before it got answered. More here. Current error messages look like: The error I get does not include any path, sadly. Is there some configuration I might be missing to include more detail in the errors? Or an extension? It is in this current state very difficult to understand what was missing or wrong. I can see here and in this current issue that the problem is supposed to be resolved, but I can't observe that on my own use. Here's what I get:
More information about the query and arguments: mutation CreateRegister($register: RegisterForCreateInput!) {
createRegister(input: {register: $register}) {
register {
id
createdAt
name
type
bookId
parentId
startsAt
expiresAt
currencyIsoCode
notes
initialBalance
active
defaultCategoryId
institutionName
accountNumber
iban
annualInterestRate
creditLimit
cardNumber
}
}
} {
"name": "InCAD",
"type": "Income",
"bookId": "e5d3b0b6-908b-49a7-a771-62c40d5bad96",
"initialBalance": 0,
"currencyIsoCode": "CAD",
"active": true
} |
@Adeynack You are not hitting the same case in your example. In the case that the PR I created originally solves is when you don't pass in a variable that should be there, we then insert https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/input_object.rb#L180 Unfortunately for the case you are hitting: https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/input_object.rb#L183 This does not actually add a What you are asking does seem to be a problem, but is probably worth a different ticket, as that seems to be the case in a couple of places where we are not passing along the |
As an aside, I realize I never got back to this issue... I switched some teams and stopped working on this stuff. @rmosolgo looking at the code I think this is still kind of a problem, but it works for now? I can go back and do my due-diligence and fix this up though if we think it's worth fixing. It's been a couple of years since I've looked at the code so I'm unsure if things have changed to make this not relevant. |
@grcooper : I found my mistake and it's a case of facepalm – and I am sorry I did not delete my message in time before you answered! – I am simply not providing the When I change my variables from {
"name": "InCAD" // etc...
} to {
"register": {
"name": "InCAD" // etc...
}
} of course then it works. Thanks for your quick reply @grcooper ! |
This PR #2985 changed how we do input validation.
The PR was pushed along fairly quickly and this issue is here to capture the questions that were asked but unanswered in favour of time to ship.
Recommendation for 1:
I believe that the best solution for 1 is to handle required arguments in their own section rather than doing it automatically with a nil check.
This would be something along the lines of:
Do we want this error messaging to stay the same however, or do we want to change it to something more specific around required arguments?
Current error messages look like:
"Variable $input of type [DairyProductInput] was provided invalid value for 0.source (Expected value to not be null)"
This happens when
source
is a required input. (Taken from the test here: https://github.com/rmosolgo/graphql-ruby/pull/2985/files#diff-3f549290bd93783c3126a4eeded156ceR317)get_argument
method and see if it needs further caching: https://github.com/rmosolgo/graphql-ruby/pull/2985/files#diff-edaedf574068dd9aee5988de3b6198fcR110The text was updated successfully, but these errors were encountered: