-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
validate field arguments #608
Conversation
Depth is hardcoded, would adding a static setter be sufficient? ResolveInfoFieldsAndArguments is fired twice if you are also using SelectField, maybe this could be moved, out, any suggestion to how you would do that @mfn ? |
@crissi ready for review? |
yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depth is hardcoded, would adding a static setter be sufficient?
ResolveInfoFieldsAndArguments is fired twice if you are also using SelectField, maybe this could be moved, out, any suggestion to how you would do that @mfn ?
Thanks for pointing this out.
IMHO yes, we definitely should improve this; ResolveInfoFieldsAndArguments
can be quite costly.
Since validation is an "always on" feature, we have to resolve this anyway so we can do it already before calling validateFieldArguments
and keep a reference to the result, which we then also pass to instanciateSelectFields()
and we can already pass it directly into \Rebing\GraphQL\Support\SelectFields::__construct
, removing/refactoring \Rebing\GraphQL\Support\SelectFields::getFieldSelection
Regarding the depth
: maybe we need to change this approach:
- we keep the default of 5 hardcoded
- but add a config to override that default
- and add the ability to define the depth optionally on the query => would that be possible (just as config option on the graphql query type?)
Does that make sense?
I might have more feedback but we should sort out the high-level stuff first, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great!
A few minor feedbacks but after that and update with master it's good to merge from my side, thank you!
@@ -123,6 +145,11 @@ protected function getResolver(): ?Closure | |||
} | |||
} | |||
|
|||
$fieldsAndArguments = (new ResolveInfoFieldsAndArguments($arguments[3]))->getFieldsAndArgumentsSelection($this->depth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the big prize question: how can we avoid resolving this if there aren't going to be any validations (they're optional after all)? Do you see any way to achieve this?
Seems like a catch-22: only when we run RulesInFields
for which we already have to extract "fields and arguments" we can then know that we wouldn't have to run it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could probably write a function that checks if any arguments exists that would be less costly than the ResolveInfoFieldsAndArguments, and then only run ResolveInfoFieldsAndArguments if using selectfields and arguments... but not sure how much it will actually give.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, let's scrap that for now!
afdaa6e
to
427d6d9
Compare
The job with the integration test is failing, I'll restart it |
hm, nope, fails too https://travis-ci.org/github/rebing/graphql-laravel/jobs/677399766#L380 :
That's 1.6GB so no point in bumping the memory_limit, something is off here. My first idea maybe something in composer changed, a newer version, but https://travis-ci.org/github/rebing/graphql-laravel/jobs/677399766#L148
I pushed a commit to see how it goes when we |
The new 2.0 as of now
https://travis-ci.org/github/rebing/graphql-laravel/jobs/677442929#L152
Ach #fail Meh, must be something else as the trace comes from within the resolver… I'll try the composer 2.0 preview, maybe we're lucky :) |
We were 🍀 ! |
Np, will make a fix later
Hent Outlook til iOS<https://aka.ms/o0ukef>
…________________________________
Fra: Markus Podar <notifications@github.com>
Sendt: Thursday, April 23, 2020 11:38:11 AM
Til: rebing/graphql-laravel <graphql-laravel@noreply.github.com>
Cc: Christian <c2n@live.dk>; Mention <mention@noreply.github.com>
Emne: Re: [rebing/graphql-laravel] validate field arguments (#608)
@crissi<https://github.com/crissi> you might already noticed, this added a regression see #627<#627>
Please feel free to "revert my revert" and apply a fix (probably the InvariantException thingy, 95% sure)
Thanks!
(and sorry for my feedback: pretty sure I was the reason why we removed it)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#608 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAXPDYQ57XSNUKHL7HZVKZDROAEAHANCNFSM4LRCJBEQ>.
|
This reverts commit fb9dace.
Summary
Fixes #602
Rules never worked in field arguments.
Type of change
Checklist
composer fix-style