Add policy for use name instead of slug (#2402)

This commit is contained in:
Patryk Andrzejewski 2022-10-20 13:55:55 +02:00 committed by GitHub
parent d67e4799b2
commit faa41039fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,25 @@ export const apolloClient = new ApolloClient({
Shop: {
keyFields: [],
},
AttributeValue: {
fields: {
/**
* Since, API sometimes creates an empty slug,
* We need to handle that case also on front-end,
* so after fix that problem in the API, the UI will ablle
* to handle it.
*
* If the slug is empty, use the name
*/
slug: (givenSlug, { readField }) => {
if (!givenSlug) {
return readField("name");
}
return givenSlug;
},
},
},
} as TypedTypePolicies,
}),
link,