Suwayomi / Suwayomi-Server

A rewrite of Tachiyomi for the Desktop
Mozilla Public License 2.0
3.69k stars 196 forks source link

Feature/gql simpilify filtering for multiple values #960

Closed schroda closed 1 week ago

schroda commented 4 weeks ago

this is a breaking change to the gql schema

Makes it easier to filter for multiple values at ones without having to nest filters with multiple "and".

e.g.

query MyQuery {
 mangas(
  filter: {genre: {includesInsensitive: "action"}, and: {genre: {includesInsensitive: "adventure"}, and: { ... }}}
 ) {
  nodes {
   id
  }
 }
}

can be simplified to

query MyQuery {
 mangas(
  filter: {genre: {includesInsensitive: ["action", "adventure", ...]}}
 ) {
  nodes {
   id
  }
 }
}

Makes it easier to filter for entries that match any value without having to nest filters with multiple "or".

e.g.

query MyQuery {
 mangas(
  filter: {genre: {includesInsensitiveAny: ["action", "adventure", ...]}}
 ) {
  nodes {
   id
  }
 }
}

instead of

query MyQuery {
 mangas(
  filter: {genre: {includesInsensitive: "action", or: {genre: includesInsensitive: "adventure", or: {...}}}}
 ) {
  nodes {
   id
  }
 }
}
Syer10 commented 4 weeks ago

Hmm, I'm not sure about this. Its already possible to do with with a more involved manner, and if this breaks those queries I'm not sure its worth it.

schroda commented 4 weeks ago

in itself the queries still work, the values would just have to be wrapped in a list (which will depend on the client, since graphql doesn't care if a single value is wrapped in a list or not)

but it's only for convenience, since I think it's kinda ugly having to create these nested filters if it's only about the breaking change, it could also be added as a new filter like <filter>All (e.g. includeAll) leaving the current filter (include) as is

Syer10 commented 4 weeks ago

I like the idea of it being a new filter. It wouldn't be a scheme break and it would add new options for those who need it

schroda commented 3 weeks ago

yeah, i've missed them, everything should be fine now

Syer10 commented 3 weeks ago

Can you add a any option for the exclude filters? Would be more useful for exclude then All