我正在使用Laravel和Lighthouse,但有一个问题,我无法使用barber_shop_id
突变来更新关系updateUserBarberShop
,但是其他任何字段都可以正常更新。如何更新这种关系?
type User {
id: ID!
first_name: String!
last_name: String!
email: String!
phone_number: String!
documents: [Document] @hasMany(relation:"documents")
photo: Media
phone_number_verified_at: DateTime
barber_shop_id: [BarberShop] @hasOne(relation:"BarberShop")
}
type BarberShop {
id: ID!
name: String!
address: String!
}
input UpdateUser {
id: ID!
first_name: String
barber_shop_id: UpdateBarberShopBelongsTo!
}
input UpdateBarberShopBelongsTo {
connect: ID
}
extend type Mutation {
updateUserBarberShop(
input: UpdateUser! @spread
): User @update
}
我对graphql服务器的请求如下:
{mutation {
updateUserBarberShop(input: {
id: 1,
barber_shop_id: {
connect: 2
}
}) {
id,
first_name
last_name,
barber_shop_id {
id
}
}
}}