Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@inject for array inputs #1879

Closed
alireza-a2f opened this issue Jun 19, 2021 · 2 comments
Closed

@inject for array inputs #1879

alireza-a2f opened this issue Jun 19, 2021 · 2 comments
Labels
enhancement A feature or improvement

Comments

@alireza-a2f
Copy link
Contributor

alireza-a2f commented Jun 19, 2021

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")
}
@spawnia spawnia added the enhancement A feature or improvement label Jun 21, 2021
@spawnia
Copy link
Collaborator

spawnia commented Jun 21, 2021

This functionality would have to be implemented here:

public function addValue(string $path, $value): self
.

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?

@nuwave nuwave deleted a comment from wilsonwg Jul 27, 2021
@spawnia
Copy link
Collaborator

spawnia commented Feb 5, 2023

Duplicate of #1206.

@spawnia spawnia closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants