I believe the number one use case will be counting for paginate data. What would be nice if possible is a way to use the same filter and results with cascade applied.
Two separate suggestions:
- Use the same filter:
If I pass in values and build a pretty complex filter and do some pagination I would want to get a total count of the filtered results that way I can quickly do a complete pagination UI display with a first, ...current..., last
option. Right now there is no good way to do this without getting all of the ids and counting them in a response which is making the client do extra work. But bottom line, I would want a way to signify to use the same filter|results from a block above. I know graphql really makes this complicated, but I think it would be possible with the graphql parser and DQL generator script that is working behind the scenes. Maybe something like this:
# generated queries
type Query {
"Placeholder for Counted Nodes, used by @count directive"
Count: Int
}
# example Query
{
getData(
filter: {
# really complex filter
}
first: 10
) @count(query: Count) {
id
}
Count # should ignore the first and offset filter properties
allData:getData @count(query: allDataCount) {
id
}
allDataCount:Count
}
the Count
query could then just be a placeholder type that returns 0 unless a count directive utilizes it with or without an alias. And maybe even some smart logic in here that if only a single @count directive is given and only a single Count query is given, then place the Count in that return. I think this is making sense, at least to me it does.
EDIT: I am not sure in my after thought if the aliases are available at the deeper level or not? Does the GraphQL client strip off the aliases and then reattach them with the returned results, or are the aliases available to the resolvers as well? I haven’t wrote a resolver for many months now which makes me quite happy!
- Work somehow with applying cascade. To explain my point here, examine this query:
{
queryData(first:5) @cascade {
id
metaData(filter: {id:["0x1"]}) {
id
}
}
}
This query gets only the data that are the parents of the metaData with the id <0x1>
. I would want to be able to count this as a total result disregarding the first directive while honoring the cascade directive. But keep in mind that @cascade still does not work with pagination, so this may be a limiting factor.