-
Notifications
You must be signed in to change notification settings - Fork 7
@defer timeout in clients #406
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
Comments
Hey @smyrick 👋 I'm curious, where are you seeing the timeout option for I'd be curious what you'd expect the behavior to be if that Would love to get some more thoughts from you on how you see this working! Appreciate the feature request 🙂 |
It is not an option directly, but something you can build with wrappers, see: https://github.com/drcallaway/apollo-link-timeout I would expect if any defer timeout was hit that it would error out the remaining response. I know that means we might get partial data back, and not Maybe to use defer timeouts it requires use of the query ProductQuery {
products {
id
name
... @defer(label: "reviews") {
reviews {
title
text
... @defer(label: "reviews.user") {
user {
name
}
}
}
}
}
} Then on query you pass in additional config useQuery(PRODUCT_QUERY, {
deferTimeout: {
"reviews": 1000,
"reviews.user": 3000
}
}) Let me ask others who more directly want to use the feature for feedback |
The customer helped with some clarifications so let me add those. I think the ideal scenario we want to support is to give a little more control to the client teams on how data is resolved and when a timeout is used. In a Federated architecture this shifts the logic from just client side to the Router + subgraphs and we need some way of communicating that from client to subgraphs as they are the ones actually resolving data. Lets use 1 client, 1 Router, 1 subgraph for simplicity. This is the operation today: query MyOperation {
products {
name
reviews {
text
}
}
} In the subgraph code we do call two different databases to resolve this, but that is hidden in the schema, but the same concept works even if this is across two subgraphs. For the query MyOperation {
products {
name @defer(timeout: 3000)
reviews {
text @defer(timeout: 5000)
}
}
} This should let subgraphs know they should wrap their resolver with a timeout block and error if that is not met. This would require a lot of coordination across client, Router, and subgraph. |
Overview
Today you can configure a timeout for a http request in apollo clients (http-link in React, ect), however
@defer
now allows us to split our operations into many smaller chunks. Operating at the HTTP level we currently can only sent a timeout for the entire request and there is no understanding that responses may be coming back in many partsSuggested Changes
Allow clients to add a timeout value or a hook for calculating one based on the
@defer
label. This would allow us to specify a timeout per chunked responseThe text was updated successfully, but these errors were encountered: