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
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);
}Related
ResultOf TadaDocumentNode VariablesOf