Negated params in GraphQL
In #234080 (closed) I'd like to add negated params for issues filtering for an epic board resolver.
Because negated params are not used in other GraphQL endpoints yet, it would be good to settle consensus about the format for negated params. As a result we should update our GraphQL styleguide.
option 1: nested under not param:
After some very helpful discussions on #graphql channel, I like Mario's suggestion:
issues(labelName: ["test", "test2"], not: {labelName: "test4", userName: "jprovaznik"})
There are a couple of good reasons for this format:
-
not:is nested as another param in a similar way we use it in REST API - IssuableFinder expects this nested
notparam so it makes it easier to convert input params into the format expected by finders - negated params can be DRYied easily with something like this https://gitlab.com/-/snippets/2002673, note that params are nested in
issueFilters, but typically we don't nest these params so maybe a concern would have to be used.
option 2: another option would be keep it flat and simple:
issues(labelName: ["test", "test2"], notLabelName: "test4", notUserName: "jprovaznik")
Major pros is that it keeps things simple and straightforward, but it requires more complicated processing of these params, also we would have to define both normal param and negated param.
option 3: flat list, but make it easier to generate negated params
Same as option 2, but we could autogenerate negated params by extending argument method and pass an negated: true to it, So something like this would define both label_name and not_label_name arguments:
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
required: false,
negated: true,
description: 'Label applied to issues'