Search code examples
asp.net-coregraphqlhotchocolate

How to add a custom field to the Payload generated by AddMutationConventions()?


I am using AddMutationConventions() to save me from writing boilerplate code. However I want to add a field query: Query to each Payload. Is that possible in combination with AddMutationConventions() or do I have to write my own Payload by hand in that case?


Solution

  • As mentioned in my comment, you can automatically add the query field to all mutation payloads with this configuration option:

    services
        .AddGraphQLServer()
        .AddQueryFieldToMutationPayloads();
    

    Reference