Open yanns opened 1 year ago
This is now supported in the Router with the new directives
https://www.apollographql.com/docs/router/configuration/authorization
type Query {
product: Product @authenticated
}
type Product @key(fields: "id") {
id: ID! @policy(policy: [["feature-a"]])
inStock: Boolean! @requiresScopes(scopes: [["read:product"]])
}
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