-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
makeRemoteExecutableSchema squares remote query field executions #1346
Comments
You need a link that batches. See https://github.com/prisma-labs/http-link-dataloader and recent developments at Gatsby: And |
The issue of n^2 queries won't be solved by batching and should be fixed in makeRemoteExecutableSchema. In the meantime, in the alpha versions, you should be able to do use the new wrapSchema function instead of makeRemoteExecutableSchema, which hopefully should not have this problem, as follows:
The intended benefit of wrapSchema is that you can create a remote schema and apply transforms with only one round of delegation. A side benefit, hopefully, is that it does not have the n^2 problem. I would refactor makeRemoteExecutableSchema to use wrapSchema under the hood. But, I am having trouble doing that in a backwards compatible way, as makeRemoteExecutableSchema takes these custom resolver arguments. Getting closer, though. |
We can add his tests as well so we will make sure it is working correctly later @yaacovCR |
@ardatan, we definitely do need a lot more tests! In the meantime, @meiamsome might you be able to confirm that this is fixed used graphql-tools@next? v5-rc.3 should have this bug fix. |
I will have a look at this and hopefully get back to you some time tomorrow or so. Thanks for the quick response so far! |
Should be fixed with latest alpha, |
May be fixed in v5, but tests are in alpha, thanks @ardatan |
Closed by #1419. |
The current default implementation of
makeRemmoteExecutableSchema
'screateResolver
will result in a query with n fields selected at the query being executed n times, meaning that the remote server will see n^2 executions of the fields at the query level.For example, with this schema:
Executing this request:
Will result in the fetcher being executed three times, and each execution will receive a document with all three fields at the query level. This means that each field will be evaluated 3 times on the server, resulting in 9 total field executions.
To illustrate the problem a bit better, I have made this commit that adds two tests that would both be acceptable solutions to the problem - either call the fetcher a single time for all fields, or call the fetcher n times but send a different request document to each: meiamsome@f81b20e
Currently running these tests results in the following failures:
The text was updated successfully, but these errors were encountered: