Mark fields / types / interfaces and skip GrapQL CRUD generation

It will be useful to also have the @generate directive operational on fields and not only on OBJECT | INTERFACE. My use-case is to populate the fields via @lambda mutation and then query via the auto-generated queries. Consider this hypothetical example:

type Person  {
   name: String! @id
   age: Int
   father: Person @generate(mutation: {
        add: false,
        update: false
    })
}

type Mutation {
    addFather(name: String!, father: String!) @lambda
}

In this example, the add and update mutations for type Person are auto-generated but will exclude the field father. These mutations can be used to add Person objects and update their age. The addFather lambda mutation can be used to add father to a Person (i.e., set the field Person.father using lambda dql). Alternatively, the planned @webhook directive can be used to populate the father field. Since the query mutations are not disabled for the field father, users can use the auto-generated query queryPerson or getPerson to query Person including the father field without writing a custom resolver.

There are few advantages to this approach, most notably its flexibility, simplicity and the ability to perform deeply nested queries that are not trivial using @custom directives.

@pawan @rajas @abhimanyusinghgaur any thoughts?

2 Likes