Skip to main content

frg

frg.ts
Utilises Tagged Templates to create a GraphQL fragment. This will append __typename to the start of the fragment and remove all new lines and multiple spaces. If the fragment starts with __typename it will not be appended. If the fragment contains __typename anywhere else, we will still append it to the start. We will not remove duplicate __typename’s. This is a simple string append, we don’t analyse the fragment.

Example

dependenciesToMappedQuery

dependenciesToMappedQuery.ts
Sometimes a field can have multiple options, for example, a Component field that can be a HeroBanner or Image. In that case you would use dependenciesToMappedQuery to map the dependencies to a query.

Before

After

Struct

struct.ts
This is a utility type that will infer the schema of a createRegistration or createDependency.

Example

resolver

resolver.ts
This is a utility function that will resolve a query using a Zod schema. It will return the data if successful, or call the onQueryError or onZodError functions if there is an error. You’ll need to provide your own getClient function and QueryInput type.

Example