A WIP idea around a simpler approach to the problem solved by @defer
. Adds a continuation field to the Query
and any types implementing the Relay Node
interface. Resolves the selection set underneath the query and executes.
npm i graphql-continuations
import { addContinuationsToSchema, memoryAdapter } from "graphql-continuations";
const schema = addContinuationsToSchema(myExistingSchema, {
adapter: memoryAdapter(), // redisAdapter() or custom adapter intended for production usage
});
fragment ExpensiveUserData on User {
id
remoteProfile {
data
}
}
query QueryWithNestedData {
viewer {
id
name
continuation(waitMs: 100) {
__typename
... on Continuation {
continuationId
}
...ExpensiveUserData
}
}
}
query ResolveUserData($cid: String!) {
resolveContinuation(continuationId: $cid) {
...ExpensiveUserData
}
}
Proper field level configuration
Feedback welcome!
MIT