-
Notifications
You must be signed in to change notification settings - Fork 433
Expose current executor's location #83
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
Conversation
This looks good, but I would like to know your use case for needing to call |
It's not related to #84. It's loosely related to #40, which #80 seeks to resolve. To me, these are all related in that they are trying to improve the ergonomics when processing multiple inputs. For my specific use case, I'm building a domain registration API. A user might want to check availability of multiple domain names at the same time. For example:- {
domains {
check(domains: ["example.com", "example.local"]) {
domain
available
}
}
} Like in the example above, some of the domains submitted may not be valid ( {
"data": {
"domains": {
"check": [
{
"available": false,
"domain": "example.com"
}
]
}
},
"errors": [
{
"message": "example.local is not a valid domain name",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"domains",
"check"
]
}
]
} I couldn't figure out any other way of achieving this besides using EDIT:-
No, it's not enough. The problem with |
It could be that I'm missing something here, but wouldn't it be more idiomatic if you used the built-in mechanisms that GraphQL provides to do batch queries (perhaps combined with fragments to keep it DRY)?
This would get you a |
TLDR: Using a I may be wrong about this but IMHO batching like that is ideal for queries that actually do different things instead of doing the same thing on different inputs. There are a number of drawbacks for batching a query like this versus simply accepting a It complicates client queries unnecessarily. Compare this:- {
domains {
check(domains: ["example.com", "example.local"]) {
domain
available
}
}
} to this:- fragment checkField on Check {
domain,
available
}
query {
domains {
alias1: check(domain: "example.com") {
...checkFields
}
alias2: check(domain: "example.local") {
...checkFields
}
}
}
Hence, I think batching in this sense is overkill for such a simple use case. There are also practical reasons why I wouldn't use it for a use case like this:-
|
I see, this seems reasonable :) May I suggest a small API change though: since you probably always will write |
@mhallin That's a good idea. Let me do that. |
@mhallin Instead of |
`executor.push_error_at()` and add a new `executor.push_error()`
173435b
to
2837084
Compare
@mhallin Done. I used |
This looks great, thanks a lot! |
Executor
has apush_error
method which is very useful for reportingback errors. However, this method needs to know the location of the
error (
SourcePosition
). This commit adds alocation
method to theexecutor.