lighthouse
lighthouse copied to clipboard
@inject for array inputs
Now you can only use @inject for simple value injections, but it could be very useful if we were able to use @inject for injecting same value into array inputs.
Inputs:
input ActivityInput {
id: ID
goal: String
}
input ActivityRelationInput {
upsert: [ActivityInput]
delete: [ID]
}
input CustomerInput {
id: ID
name: String
activities: ActivityRelationInput
}
Mutation:
extend type Mutation {
customerUpsert(input: CustomerInput! @spread): Customer
@upsert(model: "App\\Models\\Customer")
@inject(context: "user.id" name: "activities.upsert[].user_id")
}
This functionality would have to be implemented here: https://github.com/nuwave/lighthouse/blob/0d8f0fb8a3dd2791dda4c772f3db4b53ee072fb3/src/Execution/Arguments/ArgumentSet.php#L239.
The syntax should probably be the same as in array validation: activities.upsert.*.user_id.
What is supposed to happen when the client does not pass nested inputs down to that level?
Duplicate of https://github.com/nuwave/lighthouse/issues/1206.