Sha256: d0dce8d1250c5d52206f429a7b24c8f69dba86d9ebca5a85b2ea1061841e9eee
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
## GraphQL::Stitching::Planner A `Planner` generates a query plan for a given [`Supergraph`](./supergraph.md) and [`Request`](./request.md). The generated plan breaks down all the discrete GraphQL operations that must be delegated across locations and their sequencing. ```ruby document = <<~GRAPHQL query MyQuery($id: ID!) { product(id:$id) { title brands { name } } } GRAPHQL request = GraphQL::Stitching::Request.new( supergraph, document, variables: { "id" => "1" }, operation_name: "MyQuery", ).prepare! # Via Request: plan = request.plan # Via Planner: plan = GraphQL::Stitching::Planner.new(request).perform ``` ### Caching Plans are designed to be cacheable. This is very useful for redundant GraphQL documents (commonly sent by frontend clients) where there's no sense in planning every request individually. It's far more efficient to generate a plan once and cache it, then simply retreive the plan and execute it for future requests. ```ruby cached_plan = $cache.get(request.digest) if cached_plan plan = GraphQL::Stitching::Plan.from_json(JSON.parse(cached_plan)) request.plan(plan) else plan = request.plan $cache.set(request.digest, JSON.generate(plan.as_json)) end # execute the plan... ```
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-stitching-1.2.1 | docs/planner.md |
graphql-stitching-1.2.0 | docs/planner.md |