It would be nice if we could derive a schema directly from a type, for example:
type user = {
id : int [@description "Unique user identifier"];
name : string [@name "firstName"];
role : role;
}
[@@deriving graphql_object]
would generate the following code:
Schema.(obj "user"
~fields:(fun _ -> [
field "id"
~doc:"Unique user identifier"
~typ:(non_null int)
~args:Arg.[]
~resolve:(fun info p -> p.id)
;
field "firstName"
~typ:(non_null string)
~args:Arg.[]
~resolve:(fun info p -> p.name)
;
field "role"
~typ:(non_null role)
~args:Arg.[]
~resolve:(fun info p -> p.role)
])
)
thoughts?
It would be nice if we could derive a schema directly from a type, for example:
would generate the following code:
thoughts?