-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Custom Network Layer -- Modifying the RelayQueryRequest #654
Comments
This is intentional in order to keep the API surface area small, and allow faster iteration on Relay internals. In particular, allowing users or network layers to modify the query would require us to document and be careful to support the That said, it's easy to imagine how this could work in the future: RelayQueryRequest would be an observable subject, which allows multiple values to be yielded, instead of a deferred which only allows a single value. The network layer could then resolve pairs of query & reponses before closing the request to indicate all data was fetched. Before we consider that, though, what is your use case? It may very well be something we could support in the core. |
I was seeing if local data could be implemented via a Network Layer (inspired by the reactjs meetup talk by @steveluscher -- the network layer was a common answer on how to extend Relay). This will eventually be done as part of #114, so I'll close this with your answer :). The idea was having a composite network layer where a query is split and routed to different network layers -- one of which could be local (e.g. https://github.com/relay-tools/relay-local-schema). This is easy for top level fields, but is proving ridiculous if you allow arbitrary mixing ... I'm ending up post-walking the query and building up a queue of queries with each entry of the queue an array of queries capable of being done in parallel.
default network layer:
local network layer:
And then if each draft had
So basically -- a terrible idea it is turning out (ps. this doesn't work at all). Even if this did work an unfortunate thing is that you need the entire local schema on the device at once (vs having the schema downloaded incrementally attached to components). thanks! |
Hello,
This is more of an information request / check of sanity.
I'm toying around with making a custom network layer to modify / split queries. The problem I'm running into is that the
RelayNetworkLayer
interface doesn't support modifying theRelayQueryRequest
. The return value forRelayNetworkLayer#sendQueries
doesn't seem to be used for anything internally:relay/src/network/fetchRelayQuery.js
Line 50 in 02f2a3b
I can still make the custom network layer, the downside being that if I break a query into pieces I can only resolve the entire original
RelayQueryRequest
at once and would need to merge the responses.The other option would be to call
RelayStoreData#handleQueryPayload
directly and incrementally and then resolve the originalRelayQueryRequest
when all sub queries have been completed. Does this sound sane or insane?It doesn't seem really feasible to refactor
RelayNetworkLayer
to return newRelayQueryRequest
's since it puts them into the query tracker before calling the network layer (plus they network layer is called viasetImmediate
).That said,
RelayQueryNode#createNode
andRelayQueryNode#clone
are so far making it easy screw around with the query data structure.The text was updated successfully, but these errors were encountered: