[Question] Return the query root in a mutation response payload #1169
-
I would like to return the query root in a mutation response payload, as described here: https://graphql-rules.com/rules/mutation-payload-query. Is there a way to do this? I tried returning the value of |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 16 replies
-
Hmm, interesting. I have not actually seen this pattern before. I did a quick update of the example and added this function: @Component
class SimpleMutation(private val simpleQuery: SimpleQuery) : Mutation {
fun mutationQueryResponse(input: String): SimpleQuery {
// Do mutation actions with input
return simpleQuery
}
}
I wonder though if we could do something like allowing to return We usually have a specific Mutation response that you want to return so that you can better control what types of data the clients have access to after they do a mutation, but I can see the benefits of this pattern as well |
Beta Was this translation helpful? Give feedback.
-
Given a schema type Query {
foo: Foo
bar: Bar
baz: Bar
} I am unsure how useful it would be to return whole type Mutation {
updateFoo: UpdatedFoo
}
type UpdatedFoo {
result: Boolean
updated: Query
} Guess it really depends on your schema but geneally instead of the whole Since |
Beta Was this translation helpful? Give feedback.
-
Update on this, with the addition of @GraphQLType("Query")
fun doSomethingAndGetQuery(): Any {
return Any()
} |
Beta Was this translation helpful? Give feedback.
Update on this, with the addition of
@GraphQLType
you can now just set the return type to a type reference and this works