Sha256: a0c4b8d5d1f080f64846ba4ac73943fd1f796f81f2b50f10083b9bf1aee26626

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

## GraphQL::Stitching::Supergraph

A `Supergraph` is the singuar representation of a stitched graph. `Supergraph` is composed from many locations, and provides a combined GraphQL schema and delegation maps used to route incoming requests.

### Export and caching

A Supergraph is designed to be composed, cached, and restored. Calling the `export` method will return an SDL (Schema Definition Language) print of the combined graph schema and a delegation mapping hash. These can be persisted in any raw format that suits your stack:

```ruby
supergraph_sdl, delegation_map = supergraph.export

# stash these resources in Redis...
$redis.set("cached_supergraph_sdl", supergraph_sdl)
$redis.set("cached_delegation_map", JSON.generate(delegation_map))

# or, write the resources as files and commit them to your repo...
File.write("supergraph/schema.graphql", supergraph_sdl)
File.write("supergraph/delegation_map.json", JSON.generate(delegation_map))
```

To restore a Supergraph, call `from_export` proving the cached SDL string, the parsed JSON delegation mapping, and a hash of executables keyed by their location names:

```ruby
supergraph_sdl = $redis.get("cached_supergraph_sdl")
delegation_map = JSON.parse($redis.get("cached_delegation_map"))

supergraph = GraphQL::Stitching::Supergraph.from_export(
  schema: supergraph_sdl,
  delegation_map: delegation_map,
  executables: {
    my_remote: GraphQL::Stitching::RemoteClient.new(url: "http://localhost:3000"),
    my_local: MyLocalSchema,
  }
)
```

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql-stitching-0.3.6 docs/supergraph.md
graphql-stitching-0.3.4 docs/supergraph.md
graphql-stitching-0.3.3 docs/supergraph.md
graphql-stitching-0.3.2 docs/supergraph.md
graphql-stitching-0.3.1 docs/supergraph.md
graphql-stitching-0.3.0 docs/supergraph.md