FragmentOf

shopify-graphql · /index·type

Masked shape of a fragment as it appears before being unwrapped by readFragment.

Use it to type the data parameter of a component that receives a masked fragment spread, enforcing that callers pass the opaque reference rather than the unwrapped result. Call readFragment inside the component to access the actual fields.

Definition

@nordcom/commerce-shopify-graphql
type FragmentOf = TFragment extends GqlTadaDocumentNode<unknown, unknown, FragmentDecorationLike> ? GqlFragmentOf<TFragment> : never;

TFragment extends GqlTadaDocumentNode<unknown, unknown, FragmentDecorationLike> ? GqlFragmentOf<TFragment> : never

Example

import { graphql, FragmentOf, readFragment } from '@nordcom/commerce-shopify-graphql';

const PRODUCT_FRAGMENT = graphql(`
  fragment ProductFields on Product { id title }
`);

type Product = FragmentOf<typeof PRODUCT_FRAGMENT>;

function render(data: Product) {
  const product = readFragment(PRODUCT_FRAGMENT, data);
}

ResultOf TadaDocumentNode VariablesOf

Sourcegraphql.ts:131Edit the JSDoc directly
Metadata@nordcom/commerce-shopify-graphql@0.0.0Open in GitHub ↗

On this page