Reputation: 11760
I have a custom schema I need to work with, here's a slightly abbreviated version:
schema {
query: Query
}
type Query {
environment(locale: LocaleEnum!): Environment
}
type Environment {
articles(
offset: Int = 0
limit: Int = 20
): ArticleConnection!
}
type ArticleConnection {
total: Int!
items: [Article!]
}
type Article {
id: ID!
title: String!
}
I was able to get a list of article IDs by running
query {
environment(locale: EN) {
articles {
total,
items {
id
}
}
}
}
Is it possible to filter on the article id? Like, I just want a single, specific article.
Upvotes: 0
Views: 728
Reputation: 84687
Clients can manipulate the "shape" of a GraphQL service's response in one of three ways:
@skip
and @include
directives to explicitly exclude or include an individual field from the selection set.Outside of the above, GraphQL does not provide any built-in mechanisms for filtering, sorting, pagination or other arbitrary transformations of the response. These features are service-specific and have to implemented as part of your schema, which represents the collective abilities of your service.
For example, you might add another field to your Environment
type like:
type Environment {
article(
id: ID!
): Article
}
If you're developing a client that uses an existing schema, there's not much you can do if the schema doesn't expose the functionality you need.
Upvotes: 1