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

feature idea: dynamic nested mutation #2446

Closed
alidcast opened this issue Oct 31, 2017 · 1 comment
Closed

feature idea: dynamic nested mutation #2446

alidcast opened this issue Oct 31, 2017 · 1 comment

Comments

@alidcast
Copy link

alidcast commented Oct 31, 2017

I know that nested mutations are currently possible. For example:

mutation CreateNotebook(...) {
  createNotebook(...) { ... }
  createNote() { ... }
}

However, as far as I'm aware, there's no current way for the second mutation to access the query returned from the first mutation. An example use case is if a notebook must have at least one note (makes for better UX) and that a note must belong to a notebook. But since dynamic nested mutations aren't possible, instead of composing both of these mutations, I have to create a separate one, e.g. createNotebookWithNote and let the server handle the combining both actions.

The question/request: Would it be at all possible to nest mutations such that subsequent mutations can make use of queries returned from previous ones?

For example:

createNotebook(name: "example") {
   id
   name 
   createNote(notebookId: id) { // the id referenced here is of the recently created notebook
     title
   }
}

Obviously, the syntax would have to be different, and perhaps directives could be useful for this.

Has this feature been considered at all? It seems like it'd make mutations more powerful and composable, but if it's recommended to have the server handle these cases, then feel free to let me know and close this issue. :)

@alidcast
Copy link
Author

alidcast commented Nov 1, 2017

seems to be related to graphql/graphql-spec#88 and graphql/graphql-spec#212

@alidcast alidcast closed this as completed Nov 2, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant