You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also, from your example, you can't have two blocks of logic of same type, ie:
AND (
foo = 1,
OR (
bar = 2,
// below we can have either a block where zas is 3 and yus is 4 or the opposite
// thus having two times the AND block
AND (
zas = 3,
yus = 4
),
AND (
zas = 4,
yus = 3
)
)
)
@jodinathan Most of the serialization formats don't support duplicating keys including JSON and input types should be serializable in order to be passed as query parameters.
And I don't think it could be addressed without changing how input types are mapped to JSON.
Activity
sorenbs commentedon Oct 7, 2016
Fwiw, at Graphcool we generate a filter input type pretty much like you describe based on the fields in a given model.
This allows arbitrary queries like this in a typed system (and auto-complete in GraphiQL):
We are really happy with this approach.
akre54 commentedon Oct 7, 2016
You could try something like https://github.com/taion/graphql-type-json. Basic gist is to create a new GraphQLScalarType and use the serialize and parse methods.
jodinathan commentedon Oct 17, 2019
but this can make your type list increase dramatically, doesn't it?
dunno if that is a problem thought
jodinathan commentedon Oct 18, 2019
Also, from your example, you can't have two blocks of logic of same type, ie:
IvanGoncharov commentedon Oct 21, 2019
@jodinathan Most of the serialization formats don't support duplicating keys including JSON and input types should be serializable in order to be passed as query parameters.
And I don't think it could be addressed without changing how input types are mapped to JSON.
benjie commentedon Oct 23, 2019
You can, you just wrap each layer in an input object:
{allArtists(filter: { AND: [ {foo: 1}, {OR: [ {bar: 3}, { AND: [ {yas: 3}, {yus: 4} ] }, { AND: [ {yas: 4}, {yus: 3} ] } ]} ] })}(this could be expressed much simpler, but I tried to reflect your structure).