bigcommerce / catalyst

Catalyst - for Composable Commerce
https://catalyst-demo.site
MIT License
120 stars 162 forks source link

Custom Graphql is always responding null #1473

Closed kathir-arizon closed 1 month ago

kathir-arizon commented 1 month ago

Discussed in https://github.com/bigcommerce/catalyst/discussions/1455

Originally posted by **kathir-arizon** October 14, 2024 I tried to fetch the metafields based on the product ID but I am always getting the product as null when I run the same query in the playground it's working as expected. Could you please let me know if anything wrong with my code or missing something? ```ts const ProductMetaFieldsQuery = graphql( ` query ProductMetaFieldsQuery($entityId: Int!, $nameSpace: String!) { site { product(entityId: $entityId) { metafields(namespace: $nameSpace, first: 50) { edges { cursor node { entityId id key value } } pageInfo { endCursor hasNextPage startCursor hasPreviousPage } } } } }` ); export const getProductMetaFields = async (entityId: number, nameSpace: string) => { console.log('========entityId=======', entityId); const customerId = await getSessionCustomerId(); const { data } = await client.fetch({ document: ProductMetaFieldsQuery, variables: {entityId: entityId, nameSpace: nameSpace} }); console.log('========data=======', data); }; ``` Response in CLI: ``` ========entityId======= 41110 ========data======= { site: { product: null } } ```
kathir-arizon commented 1 month ago

Closing this issue. Its due to the product is not assigned to the catalyst channel and meta fields permission issues.