@generate causes server panic if only the update mutation for a type is set to true

What version of Dgraph are you using?

Dgraph Cloud v21.03.0-92-g0c9f60156

Tell us a little more about your go-environment?

No response

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

Tier: 2R
Storage: 32 GB
Dgraph Hosted: Yes
High Availability: No
SLA: 99.5%
Schema Mode: Flexible

This error can also be reproduced on a Shared Cluster (Free Tier) with a minimal schema.

What steps will reproduce the bug?

1. Add any type to the schema, eg

type GeneateTest 
  @generate(query: { query: true, get: false, aggregate: false }, mutation: {add: false, update: true, delete: false}) { 
  id: ID! test: String 
}

2. Deploy the schema

Note

If just a single generate for mutations is set, the server will respond with a Panic when running the single generated mutation.###

Expected behavior and actual result.

Expected behaviour

We’d expect that, regarding to which mutations Dgraph auto-generates, we can run these mutations.

Actual result

Running the mutation

mutation { 
  updateGenerateTest(
    input: { 
      filter: { id: "0x1" }, 
      set: { test: "testing" } 
    } 
  ) { 
    numUids
 } 
}

results in a Server Panic.

Additional information

The following tests have been executed

  • mutation: { add: false, update: true, delete: false } → fails
  • mutation: { add: true, update: true, delete: false } → ok
  • mutation: { add: false, update: true, delete: true } → ok
  • mutation: { add: true, update: false, delete: false } → ok
  • mutation: { add: false, update: false, delete: true} → ok
  • @generate for query seems not to be affected

Server Error

“Internal Server Error - a panic was trapped. This indicates a bug in the GraphQL server. A stack trace was logged. Please let us know by filing an issue with the stack trace.”