Hi, I would like to know how to define a field that contains a mixed object?
If by mixed object you mean an object you don't know the shape of you could serialize it when writing it to the backend and rehydrate it on your clients.
There is also an outstanding PR that introduces plain JavaScript Objects as a first class GraphQL-type, see #172.
Sorry for losing track of this issue.
Currently there is no Mixed type (that is, the "bottom" type or "dynamic" type) for fields that would allow for _anything_ to be returned.
However there is a Union type which may better fit what you need. Union describes a few different possible types and ensures the response is one of those types.
For future googlers:
@taion released awesome scalar GraphQLType JSON that supports dynamic values for a field!
I'm using it in graphql-compose-mongoose, so live demos with dynamic field's type can be found here:
Don't give me too much credit here. Everything eventually goes back to https://github.com/graphql/graphql-js/pull/242.
@taion you may point it in your repo. But I found your solution, that was easy to integrate and works like a charm. So all my credits belong to you ;p
Most helpful comment
For future googlers:
@taion released awesome scalar GraphQLType JSON that supports dynamic values for a field!
I'm using it in graphql-compose-mongoose, so live demos with dynamic field's type can be found here: