- Create valid access role that later will be extended with the use of
@access
directive:query {
films {
director
title
}
}
- Add definition of
@access
directive to your service schema:directive @access(
role: [String] = ["allowed role"]
depth: Int
) on FIELD_DEFINITION
- Assign
@access
directive for the field to which you want to grant access:type Query {
...
planets: [Planet!]! @access(role:["superuser"])
}
- Finally, add configuration schema to your service config: ```service.yml kind: Service spec: … schema_files:
- ../../go/starwars/graphql/schema.graphql ```
- After applying service config the of resulting access role will look like this:
superuser : query { films { director title } planets { * } }
—