@microsoft/rayfin-data package
Classes
| AggregationNotSupportedError |
Thrown when an aggregation query ( This happens when the Rayfin host has not enabled GraphQL aggregation
( Catch this error to detect a host that does not support aggregation and fall back or surface guidance to the user. |
| DataApi |
Data-specific operations client for interacting with Data API Builder GraphQL endpoints. Use the |
| GraphQLAggregationBuilder |
Fluent builder for a Data API Builder (DAB) Instances are returned from
GraphQLQueryBuilder.groupBy or
GraphQLQueryBuilder.aggregate.
The generated GraphQL contains only a Example
|
| GraphQLClient |
GraphQL client for executing raw queries and mutations against a Data API Builder endpoint. Prefer the fluent entity API ( |
| GraphQLEntityClient |
Type-safe fluent client for reading and mutating a single Data API Builder
entity. Instances are typically obtained via the Query methods ( Example
|
| GraphQLQueryBuilder |
Fluent GraphQL query builder for constructing and executing complex queries. |
| ResponseHandler |
Utilities for unwrapping Data API Builder (DAB) GraphQL response envelopes. |
Interfaces
| AggregationFieldOptions |
Options object for a single aggregation operation. |
| AggregationOps |
All valid aggregation operation entries for an entity, before the exactly-one-key constraint is applied. All operations ( |
| BooleanFilterInput |
Comparison operators for filtering boolean fields (DAB-compliant). |
| DateFilterInput |
Comparison operators for filtering date fields. WARNING: DAB currently does not support comparison operators for Date fields in PostgreSQL. |
| GenericFilterInput |
Fallback equality operators for fields without a specialized filter type. |
| GraphQLRequest |
GraphQL request payload. |
| GraphQLResponse |
GraphQL response payload. |
| GroupedAggregationRow |
Result shape of a grouped aggregation query. |
| GroupedAggregationStage |
The grouped-aggregation stage returned by GraphQLQueryBuilder.groupBy. This stage exists to thread the concrete tuple of grouped keys ( Only |
| NumberFilterInput |
Comparison operators for filtering numeric fields (DAB-compliant). |
| PagedResult |
Forward-pagination result wrapper returned by |
| PaginationConfig |
DAB pagination configuration (forward pagination only). Microsoft Data API Builder only supports forward pagination with See https://learn.microsoft.com/en-us/azure/data-api-builder/keywords/after-graphql See https://learn.microsoft.com/en-us/azure/data-api-builder/keywords/first-graphql |
| StringFilterInput |
Comparison operators for filtering string fields (DAB-compliant). |
Type Aliases
| AggregationEntry |
A single aggregation-spec entry: exactly one operation with its value. |
| AggregationOpName |
The five aggregation operation names supported by DAB. |
| AggregationOpValue |
Shorthand-or-options value for an aggregation operation. |
| AggregationResult |
Result type for a single aggregation entry.
|
| AggregationSpec |
The full aggregation specification: a map of Builder-chosen aliases to single-operation entries. |
| CertainSelectionFields |
Selection entries typed as a single field literal, so the field is known to be selected. |
| CleanEntityKeys |
Clean entity keys that exclude prototype methods and functions |
| ComputedMutationInput |
Mutation input written with computed property names, such as
|
| CreateInput |
Input type for creating new entities. The primary key field is optional since it's typically database-generated, but can be provided if the user wants to specify a particular id. |
| EligibleMutationValue |
Input values that a create or update result echoes back: scalars (including
|
| EntitySchema |
Base entity schema type for the client. |
| ExactSelectionResult |
Result shape when every selected field is a known literal: the selected scalar fields plus each selected relationship, narrowed to its nested fields. |
| ExactlyOne |
A discriminated union that enforces exactly one key from Each variant requires one key and marks all other keys as |
| FieldFilterInput |
Field-specific filter operators per DAB specification |
| FieldSelection |
Type-safe scalar and one-level relationship selection.
Use |
| FilterInput |
DAB-compliant filter input type |
| FilterValue |
Filter value that can be a direct value, a filter input, or a relationship isNull filter |
| GraphQLResponseValue |
Values returned by GraphQL without runtime field metadata. Dates and booleans may arrive as strings and cannot be distinguished from text fields by inspecting their contents. Other scalar objects stay atomic. |
| IsRelationship |
Detects if a type is a relationship (object with a primary key that's not a primitive wrapper). |
| IsUnion |
Resolves to |
| MergeProjection |
Combines guaranteed fields with fields that might also be selected. Fields
only in |
| MergeProjectionValue |
Merges one field's guaranteed projection with nested fields that might also be selected. The possible extras are added as optional fields. |
| MutationInput |
Transforms an entity type for mutation input.
|
| MutationInputValue |
The mutation input type for one entity field. Relationship fields accept a
keyed reference (see RelationshipInput) and cannot be set to |
| MutationResponseValue |
The result type of one mutated field value. Scalars and |
| MutationResult |
Computes the entity fields returned by a create or update mutation. DAB returns the primary key plus primitive input fields. Relationship inputs are returned as primary-key-only nested objects by the SDK. Non-Date, non-keyed objects are omitted. Arrays are serialized and selected by the runtime, but their response is not guaranteed by this result contract. |
| MutationResultKey |
Fields of |
| MutationResultValue |
The result type of field |
| NestedFieldPath |
Selectable scalar fields and one-level relationship paths.
Collections require |
| NestedSelectionKeys |
Fields selected under the relationship |
| NestedSelectionResult |
The relationship fields of a selection result, each narrowed to the nested fields selected for it. |
| NestedSelectionRoots |
Relationship names used as the root of nested selection paths, such as
|
| NoExtraKeys |
Rejects mutation inputs with keys that |
| NumericKeys |
Numeric keys of an entity, used to constrain the |
| OptionalProjectionValue |
Recursively marks object fields optional while keeping scalar and array shapes. Used for fields a response might include but cannot guarantee. |
| OrderByInput |
DAB order by input |
| PartiallyCertainSelectionResult |
Result shape when some selection entries are single field literals and others are unions. Known fields are required and the rest are optional. |
| PrimaryKeyOnly |
Describes the root entity's primary key result.
Models without a declared key use the schema's implicit UUID See RelationshipInput for usage in mutation input types |
| ProjectNestedElement |
Narrows one related object to the selected keys |
| ProjectNestedValue |
Narrows a relationship value to the selected keys |
| ProjectionSafeMembers |
Custom members of a GraphQLQueryBuilder subclass that stay available
on a RowQueryBuilder: the keys the subclass declares in a readonly
|
| ProjectionScalar |
Supported scalar values that must remain atomic during projection.
Infer Node's Buffer from its constructor when available: referring directly
to an absent ambient Buffer would widen browser projections to |
| RelationshipInput |
Flexible input type for relationship fields in mutations. Accepts either:
Example
|
| RelationshipInputBranch |
The relationship input accepted for one related entity type |
| RelationshipIsNullFilter |
DAB-compliant filter input |
| RelationshipKeyField |
The key field that identifies a related entity in relationship inputs and
results: |
| RelationshipKeyOnly |
A reference to a related entity that contains only its key, such as
|
| RelationshipMembers |
The members of |
| RelationshipProjection |
An optional, recursively projected view of a related entity. Relationship inputs accept it so objects returned by a selection can be passed back; only the key is written. |
| RelationshipResult |
How a relationship appears in a mutation result: an object containing only
the related entity's key, returned as |
| RequiredKeyFields |
Picks the key fields |
| RequiredMutationResultKey |
The MutationResultKey fields that are always present in the result,
because |
| RowBuilderMethod |
Built-in GraphQLQueryBuilder methods that RowQueryBuilder
retypes or hides. Listing one in |
| RowQueryBuilder |
The row-query surface of GraphQLQueryBuilder: every capability except
the aggregation entry points ( The chainable row methods ( The terminals ( Subclass members are hidden unless their keys are explicitly declared in
Example
|
| ScalarKeys |
Scalar keys of an entity — string, number, boolean, or Date. Excludes relationship, array, and nested object fields, matching the
|
| SelectionLeafKeys |
Field names of |
| SelectionResult |
Computes the entity shape returned by a GraphQL field selection. Scalar fields become a top-level |
| Simplify |
Flattens an intersection into a single object type, so editor hovers show the resolved fields of a query or mutation result. |
| TypedDataClients |
Type-safe data clients based on entity schema. |
| UncertainSelectionFields |
Selection entries typed as a union of fields, so any one of them might be selected. |
| UncertainSelectionResult |
Result shape when the selected fields are not known exactly, such as a selection typed as a widened array. Every field that might be selected is optional. |
| UnionKeys |
Every key declared by any member of the union |
| UpdateInput |
Input type for updating existing entities. All fields are optional. Relationship fields accept keyed full or projected objects, or primary-key-only. Array inputs are accepted, but do not guarantee returned relationship fields. Example
|
| WhereUniqueInput |
Input type for uniquely identifying an entity. Uses the centralized PrimaryKeyField type alias. |
Functions
| create |
Create a type-safe DataApi instance for interacting with Data API Builder GraphQL endpoints. Example
|
| data |
Register typed app-owned data on a composed Rayfin client. Reuses the existing GraphQL entity clients and their query and mutation semantics. Example
|
| deserialize |
Deep transform a DAB response into plain TypeScript objects. Two modes:
Invalid ISO strings on a |
| deserialize |
|
| deserialize |
|
| format |
Formats a value for inline use in a GraphQL query string. Applies proper escaping for strings (backslash, quote, newline, carriage return, tab). |
Function Details
createDataApi<TSchema>(ApiClient)
Create a type-safe DataApi instance for interacting with Data API Builder GraphQL endpoints.
Example
const dataApi = createDataApi<{
User: User;
Organization: Organization;
}>(apiClient);
// GraphQL fluent interface (direct entity access):
const activeUsers = await dataApi.User
.select(['id', 'name', 'email'])
.where({ isActive: { eq: true } })
.orderBy({ createdAt: 'desc' })
.execute();
// GraphQL mutations:
const newUser = await dataApi.User.create({
email: 'user@example.com',
name: 'Jane Doe'
});
function createDataApi<TSchema>(apiClient: ApiClient): DataApi<TSchema> & TypedDataClients<TSchema>
Parameters
- apiClient
- ApiClient
The ApiClient instance for making HTTP requests
Returns
DataApi<TSchema> & TypedDataClients<TSchema>
A fully typed DataApi instance with direct entity access
dataService<TSchema>()
Register typed app-owned data on a composed Rayfin client. Reuses the existing GraphQL entity clients and their query and mutation semantics.
Example
services: { data: dataService<{ Todo: Todo }>() }
function dataService<TSchema>(): ClientServiceFactory<DataApi<TSchema> & TypedDataClients<TSchema>>
Returns
ClientServiceFactory<DataApi<TSchema> & TypedDataClients<TSchema>>
A factory for the client's typed data service.
deserializeDabResponse<T>(readonly unknown[], EntityClass<T>)
Deep transform a DAB response into plain TypeScript objects.
Two modes:
Structure-only (no
entityargument, default). Walks arrays and objects and preservesDateinstances, but never value-sniffs strings for booleans or dates. A@text()or@set('true', 'false')field is byte-identical on the wire to a@date()or@boolean()field — only the declared decorator type can disambiguate them, and that metadata is not available here. Callers that need aDateorbooleanfrom a known column must convert explicitly (e.g.new Date(row.createdAt)ordeserializeBoolean(row.isActive)).Metadata-aware (with an
entityclass argument). Uses the decorated entity metadata to convert only@date()strings toDateinstances and@boolean()strings to booleans. Fields declared as@text(),@set(), etc. remain strings even when their contents look like dates. Relationship fields recurse with the target entity's metadata. Invalid date strings on a@date()field are preserved as strings rather than becomingInvalid Date.
Invalid ISO strings on a @date() field are preserved as strings rather
than becoming Invalid Date; callers should defend against untrusted
wire data since the declared type still says Date.
function deserializeDabResponse<T>(data: readonly unknown[], entity: EntityClass<T>): T[]
Parameters
- data
-
readonly unknown[]
The DAB response payload (row, list of rows, or nested shape).
- entity
-
EntityClass<T>
Optional decorated entity class produced by @entity().
When provided, the returned value matches the declared TypeScript
types of the entity (e.g. @date() createdAt: Date is a real Date).
Returns
T[]
deserializeDabResponse<T>(unknown, EntityClass<T>)
function deserializeDabResponse<T>(data: unknown, entity: EntityClass<T>): T
Parameters
- data
-
unknown
- entity
-
EntityClass<T>
Returns
T
deserializeDabResponse<T>(unknown)
function deserializeDabResponse<T>(data: unknown): T
Parameters
- data
-
unknown
Returns
T
formatGraphQLValue(any)
Formats a value for inline use in a GraphQL query string. Applies proper escaping for strings (backslash, quote, newline, carriage return, tab).
function formatGraphQLValue(value: any): string
Parameters
- value
-
any
Returns
string