Crate grafbase_sdk

Source
Expand description

§Grafbase SDK for Gateway Extensions

docs.rs

This crate provides building blocks for creating Grafbase Gateway extensions.

There exist four kinds of extensions today:

  • [AuthenticationExtension]: Authenticates clients before any GraphQL processing, generating a token with custom data for further extensions.
  • [AuthorizationExtension]: Control access to certain fields, objects, interfaces, scalars or enums.
  • [ResolverExtension]: Called by the gateway to resolve data for a field from a GraphQL subgraph.
  • [HooksExtension]: Called by the gateway to perform actions before receiving a request, or right before sending a response.
  • [ContractsExtension]: Called by the gateway to identify which elements should be part of a schema contract given subgraph directives and the contract key.

Each extension has its dedicated documentation and tutorial you can follow through.

§Features

  • test-utils — Test utilities to write integration tests for your extension. The Grafbase CLI will automatically generate an example test with the grafbase extension init command. You can also check out Grafbase’s extension repository for examples
  • jq-selection — Utilities to use jq-like selection to process data in your extension like the rest extension.

Modules§

host_io
Host IO modules.
jq_selection
A module for performing JQ filter selections on JSON data.
test
Test utilities for running and interacting with a GraphQL gateway.
types
Type definitions of the input and output data structures of the SDK.

Structs§

SdkError
Internal SDK error.

Derive Macros§

AuthenticationExtension
A proc macro for generating initialization code for an authentication extension.
AuthorizationExtension
A proc macro for generating initialization code for an authentication extension.
ContractsExtension
A proc macro for generating initialization code for a contracts extension.
HooksExtension
ResolverExtension
A proc macro for generating initialization code for a resolver extension.