The ORM is available in the request context of your operation handlers, webhooks, and hook server via the
Our ORM is currently alpha so expect bugs and API changes. Please report bugs and feature requests on GitHub 🙏
Since the ORM is experimental you must explicitly opt-in to said functionality. Set
true in your
The ORM supports read, write, and subscribe operations on the data sources configured in your WunderGraph application.
Read operations are specified via the
query method. For example,
Write operations are specified via the
mutate method. For example,
Stream operations are specified via the
subscribe method. For example,
Nested and Filtered Selections
As a convenience the ORM will select all scalar fields on an object type. In-order-to retrieve relations (or other arbitrarily nested fields on the object) and/or filter unwanted fields, one can provide a list of property paths to the
select method. For example,
An important feature of the ORM is the support for interacting with types that are variable at runtime. As our virtual graph utilizes GraphQL to define it's semantics, the ORM encodes this behavior similarly.
A union defines a set of possible types that the returned object may represent. The ORM currently requires specifying the fields you would like returned for each possible type. Select type-specific fields using the
on(fields: ...Array<string>) method, for example:
You can add headers to your ORM requests by using the
withHeaders method. For example:
An interface defines a common set of properties that multiple objects can adhere to. For example, a
Query.node(id: ID!) API (under the
foo namespace) could be accessed like so:
Note: The ORM does not currently auto-select interface fields (i.e each field must be selected on each type). This will be improved soon!