-
Hello everyone! I've some experience with GraphQL and I'm using typescript, however, I cannot grasp how to do this. I made a db similar to this: Both Services and Brands tables are already filled with items And I want to create a single mutation that fills every field from Shops and include and array of services and brands, filling both ShopServices and ShopBrands tables. Also, the owner_id is a preset using x-hasura-user-id I'm able to generate a mutation doing something like this: Then, I want to use arguments to be able to use it with a simple fetch function, adding both query and variables into a single "stringified", however, when doing so, I got this I don't know how to tackle both $shop_services and $shop_brands variables nor how should I handle the variables. What should I do? Please, any help or pointers will be very very appreciated. Regards! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
We would suggest you to use "Input Types" for complex object types (e.g. shop_services and shop_brands in your case), which can make your mutations simpler to manage. You can refer to the official GraphQL document on the same: https://graphql.org/learn/schema/#input-types In your case, you are looking at passing an array of these Input Types (shop_services and shop_brands) as part of the mutation. Please checkout some illustrations on our Hasura docs page too: |
Beta Was this translation helpful? Give feedback.
We would suggest you to use "Input Types" for complex object types (e.g. shop_services and shop_brands in your case), which can make your mutations simpler to manage. You can refer to the official GraphQL document on the same:
https://graphql.org/learn/schema/#input-types
In your case, you are looking at passing an array of these Input Types (shop_services and shop_brands) as part of the mutation.
Please checkout some illustrations on our Hasura docs page too:
https://hasura.io/docs/latest/mutations/postgres/insert/