graphql-continuations
v0.4.0
Published
An alternative approach to @defer in resolving expensive GraphQL fields
Readme
GraphQL Continuations
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-continuationsTry it out:
import { addContinuationsToSchema, memoryAdapter } from "graphql-continuations";
const schema = addContinuationsToSchema(myExistingSchema, {
adapter: memoryAdapter(), // redisAdapter() or custom adapter intended for production usage
});Overview / Summary:
https://htmlpreview.github.io/?https://github.com/tgriesser/graphql-continuations/blob/main/docs/index.html
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
}
}TODO:
Proper field level configuration
Feedback welcome!
License
MIT
