我有几个查询的返回类型相同:
// Query 1
gql`
mutation insert_shops_users($shopId: uuid) {
insert_shops_users(objects: [{ shopId: $shopId }]) {
affected_rows
returning {
Shop {
id
users {
userId
}
}
}
}
}
`,
// Query 2
gql`
mutation delete_shops_users_by_pk($shopId: uuid!, $userId: String!) {
delete_shops_users_by_pk(shopId: $shopId, userId: $userId) {
Shop {
id
users {
userId
}
}
}
}
`,
现在,我想提取该部分,例如以名称ShopUserResult
并将其用于两个查询中:
Shop {
id
users {
userId
}
}
// Query 1 - after refactor
gql`
mutation insert_shops_users($shopId: uuid) {
insert_shops_users(objects: [{ shopId: $shopId }]) {
affected_rows
returning {
ShopUserResult
}
}
}
`,
// Query 2 - after refactor
gql`
mutation delete_shops_users_by_pk($shopId: uuid!, $userId: String!) {
delete_shops_users_by_pk(shopId: $shopId, userId: $userId) {
ShopUserResult
}
}
`,
我是graphql的新手,非常感谢您提供有关重构的任何建议。
答案 0 :(得分:0)
可以使用片段(source 1,source 2)重构重复的字段集:
C:\Users\...\SendMails.vbs(3, 1) Microsoft Excel: Microsoft Excel cannot access the file
'C:\Users\...\Macro.xlsm'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
Finished: SUCCESS
gql`
mutation insert_shops_users($shopId: uuid) {
insert_shops_users(objects: [{ shopId: $shopId }]) {
affected_rows
returning {
Shop {
id
users {
userId
}
}
}
}
}
`,
询问
const ShopWithUsers = gql`
fragment ShopWithUsers on shops {
id
users {
userId
}
}
`