Convert Yojson to object?

OK, so you’re talking about ocaml-graphql-server, which programmatically defines a GraphQL schema using OCaml code, and is distinct from the GraphQL PPX: ocaml-graphql-server/graphql_intf.ml at d615cbb164d4ddfdc2efeb246a198dfe114adf24 · andreas/ocaml-graphql-server · GitHub

But you are also talking about the GraphQL PPX, so looks like you are using that as a client codegen tool, distinct from the use of ocaml-graphql-server. So, if the GraphQL query wants an object, the object will have a very specific schema. It won’t be arbitrary. So imho writing a helper function to construct the argument object is still a good approach, e.g.

let arg a b = object
  method a = a
  method b = b
end

And call with:

MyQuery.make ~arg:(arg 1 true)...

Yes, it’s the inconvenience of writing that helper that inspired my original post. There are dozens of records involved.