Sha256: 942d4ececdf9886c2620da80d0c43b2dc03daba84f978ccd65b9b866cb85154e

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

## GraphQL::Stitching::Request

A `Request` contains a parsed GraphQL document and variables, and handles the logistics of extracting the appropriate operation, variable definitions, and fragments. A `Request` should be built once per server request and passed through to other stitching components that utilize request information.

```ruby
source = "query FetchMovie($id: ID!) { movie(id:$id) { id genre } }"
request = GraphQL::Stitching::Request.new(
  supergraph,
  source,
  variables: { "id" => "1" },
  operation_name: "FetchMovie",
  context: { ... },
)
```

A `Request` provides the following information:

- `req.document`: parsed AST of the GraphQL source
- `req.variables`: a hash of user-submitted variables
- `req.string`: the original GraphQL source string, or printed document
- `req.digest`: a SHA2 of the request string
- `req.normalized_string`: printed document string with consistent whitespace
- `req.normalized_digest`: a SHA2 of the normalized string
- `req.operation`: the operation definition selected for the request
- `req.variable_definitions`: a mapping of variable names to their type definitions
- `req.fragment_definitions`: a mapping of fragment names to their fragment definitions

### Request lifecycle

A request manages the flow of stitching behaviors. These are sequenced by the `Client`
component, or you may invoke them manually:

1. `request.validate`: runs static validations on the request using the combined schema.
2. `request.prepare!`: inserts variable defaults and pre-renders skip/include conditional shaping.
3. `request.plan`: builds a plan for the request. May act as a setting for plans pulled from cache.
4. `request.execute`: executes the request, and returns the resulting data.

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
graphql-stitching-1.5.1 docs/request.md
graphql-stitching-1.5.0 docs/request.md
graphql-stitching-1.4.3 docs/request.md
graphql-stitching-1.4.2 docs/request.md
graphql-stitching-1.4.1 docs/request.md
graphql-stitching-1.4.0 docs/request.md
graphql-stitching-1.3.0 docs/request.md
graphql-stitching-1.2.5 docs/request.md
graphql-stitching-1.2.4 docs/request.md
graphql-stitching-1.2.3 docs/request.md
graphql-stitching-1.2.2 docs/request.md