You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It's complicated in plugins to override the default implementation of the resolution of each field.
(2) for each field, check if the value found in the @scope directive matches the scopes from the OAuth token. If not, disallow the resolution of this field (and add an error). Example in sangria
Example 2: feature toggles
Let's consider the supergraph SDL:
type Query {
reviews: [Review!]!
users: [User!]! @feature(name: "review-user")
}
type User @feature(name: "review-user") {
name: String!
}
The field users (and the type User) is only enabled for customers that have access to the feature tag review-user.
A feature toggle plugin could:
(1) check which feature tags a request can use, and put them into the context
(2) implement such callbacks:
before each field, check if the field can be accessed or not.
before each field, if the query is like __type(name: "User"), override the resolution to return None if the query should not access the User type.
after each field, if it was an introspection result (like { __schema { queryType { name, fields { name } } } }), remove all types that should not be seen
We have implemented such a middleware in Scala with sangria, and it's working great for us.
Describe the solution you'd like
Having middleware that can add callbacks before and after each field resolution. Middlewares could then run some logic before or after a field is resolved to override the default implementation, to add errors, or to manipulate the result.
Is your feature request related to a problem? Please describe.
It's complicated in plugins to override the default implementation of the resolution of each field.
Example 1: checking permissions
Let's consider the supergraph SDL:
A OAuth plugin could:
@scope
directive matches the scopes from the OAuth token. If not, disallow the resolution of this field (and add an error). Example in sangriaExample 2: feature toggles
Let's consider the supergraph SDL:
The field
users
(and the typeUser
) is only enabled for customers that have access to the feature tagreview-user
.A feature toggle plugin could:
__type(name: "User")
, override the resolution to returnNone
if the query should not access theUser
type.{ __schema { queryType { name, fields { name } } } }
), remove all types that should not be seenWe have implemented such a middleware in Scala with sangria, and it's working great for us.
Describe the solution you'd like
Additional context
The text was updated successfully, but these errors were encountered: