Expand description
§Grafbase SDK for Gateway Extensions
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.
- [FieldResolverExtension]: Called by the gateway to resolve data for a field, replacing or augmenting a GraphQL subgraph.
- [SelectionSetResolverExtension]: Called by the gateway to resolve data downstream from a field, replacing or augmenting a GraphQL subgraph. These extensions have access to the selection set on the field and to the whole GraphQL schema.
- HooksExtension: Called by the gateway to perform actions before receiving a request, or right before sending a response.
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 thegrafbase extension initcommand. You can also check out Grafbase’s extension repository for examplesjq-selection— Utilities to usejq-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.
Traits§
- Authentication
Extension - An authentication extension is called before any request processing, authenticating a user with a token or returning an error response.
- Authorization
Extension - An authorization extension can grant or deny access to fields, objects, interfaces, unions, scalars or enums. It’s composed of two parts:
- Hooks
Extension - The Hooks extension allows you to hook into an incoming request or an outgoing response.
- Into
Query Authorization - Into
Subscription - Resolver
Extension - A resolver extension is called by the gateway to resolve a specific field.
- Subscription
- A trait for consuming field outputs from streams.
Derive Macros§
- Authentication
Extension - A proc macro for generating initialization code for an authentication extension.
- Authorization
Extension - A proc macro for generating initialization code for an authentication extension.
- Hooks
Extension - Resolver
Extension - A proc macro for generating initialization code for a resolver extension.