Hello all,
I read about the "Adding your own Queries and Mutations" but I didn't find any explanation about extending an existing type.
For example, I have collection called product where I have shopifyId field.
I would like to be able to update the product query to able to have a node "shopify"
{
products {
shopifyId
shopify {
price
}
}
}
Do you have way?
I was thinking to override the schema, I found the code but we should provide a way to merge the schema using for example @graphql-tools/merge
Hey @b-barry — you should not directly modify the auto-generated GraphQL types, but what you're doing should be possible by adding a field to your config itself. You can then set admin.disabled: true
on the field to have it hide from the admin UI entirely. And then you could fill the field's value dynamically with hooks / similar, therefore treating it as a "virtual field". We have a demo of this coming out shortly, so keep an eye out!
Thanks for the quick response. About the hidden field, do you plan to save it the database ?
I prefer not to be sure to have the latest data
You don’t need to save the field to the database, and you can populate it dynamically with hooks. That’s actually what I was intending and is a pattern that we use ourselves quite a bit. It works well and accomplishes exactly what you’re looking to do 👍
Super ! I am looking forward for your example.
Thanks again for the response
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.