3 ms·
When building out a GraphQL schema, the schema developer chooses which functionality to expose to the client. So rather than having the client do operations or
by dschafer 11y ago
When building out a GraphQL schema, the schema developer chooses which functionality to expose to the client. So rather than having the client do operations or predicates directly, the server declares what functionality is available, and might expose functionality that ordinarily would have used operators or predicates.
For example, we might have the following query on Facebook's GraphQL schema:
{
user(id: 4) {
followers(isViewerFriend: true, birthdaysInRange: {before: -2, after: 2} orderBy:NAME) {
name
}
}
}
EDIT: fix code formatting
Which fetches Zuck's followers, and filters it to only my friends, and only those friends whose birthdays are within two days of today, and then orders them by name.
The `isViewerFriend`, `birthdaysInRange` and `orderBy` parameters were explicitly added to the API by the API developer for clients to use.
So clients don't have the ability to do arbitrary operators, but we also know that the client is only using functionality in the API that the API developer chose explicitly to allow.
- 15155 11y agoAny idea when this will work with Relay?
- masterj 11y agoThis is how Relay currently works
- 15155 11y agoYou can't presently pass other filtering arguments to a relay query. Just IDs. Unless I am missing something, the above query wouldn't work in Relay.
- TheMakeA 11y agoYou totally can. One restriction (that you might be confused with) is that Relay currently only supports root fields with a single argument (which would typically be an ID). But arbitrary arguments on any other field are totally supported.