About the GraphQL input and auto-generated schema

With dgraph, if in the input graphql schema there is a type with a predicate that is of another defined type in the schema, will a mutation be automatically generated to assign/add object to the predicate?

For example,

Type Mammal {   
  id: ID!
  cats: [Cat]
} 

Type Cat {   
  id: ID! 
}

In that case, with dgraph, will the function to add cats to mammal, something like AddMammalCats, be automatically generated to be used in Graphql? This was being auto-generated before when not using dgraph but wanted to double check if it would be the same with dgraph because currently it is not being auto-generated.

it should generate the addMammal and updateMammal mutations allowing you to do:

mutation  {
  addMammal(input: [{
    # mammal fields here
    cats: [{
      # cat fields here
    }]
  }]) { numUids }
}

or

mutation  {
  updateMammal(input: {
    filter: { id: [
      # uid(s) of mammal(s) to update here
      "0x2"
    ]}
    set: {
      # mammal fields to set here
      cats: [
        #cats to add or link by reference here
        { id: "0x3" }
      ]
    }
  }) { numUids }
}
1 Like