-
- Downloads
There was an error fetching the commit references. Please try again later.
Improve GraphQL Authorization DSL
Previously GraphQL field authorization happened like this: class ProjectType field :my_field, MyFieldType do authorize :permission end end This change allowed us to authorize like this instead: class ProjectType field :my_field, MyFieldType, authorize: :permission end A new initializer registers the `authorize` metadata keyword on GraphQL Schema Objects and Fields, and we can collect this data within the context of Instrumentation like this: field.metadata[:authorize] The previous functionality of authorize is still being used for mutations, as the #authorize method here is called at during the code that executes during the mutation, rather than when a field resolves. https://gitlab.com/gitlab-org/gitlab-ce/issues/57828
Showing
- app/graphql/types/issue_type.rb 4 additions, 6 deletionsapp/graphql/types/issue_type.rb
- app/graphql/types/merge_request_type.rb 1 addition, 3 deletionsapp/graphql/types/merge_request_type.rb
- app/graphql/types/project_type.rb 4 additions, 6 deletionsapp/graphql/types/project_type.rb
- app/graphql/types/query_type.rb 2 additions, 3 deletionsapp/graphql/types/query_type.rb
- config/initializers/graphql.rb 4 additions, 0 deletionsconfig/initializers/graphql.rb
- doc/development/api_graphql_styleguide.md 17 additions, 7 deletionsdoc/development/api_graphql_styleguide.md
- lib/gitlab/graphql/authorize.rb 0 additions, 15 deletionslib/gitlab/graphql/authorize.rb
- lib/gitlab/graphql/authorize/authorize_resource.rb 15 additions, 2 deletionslib/gitlab/graphql/authorize/authorize_resource.rb
- lib/gitlab/graphql/authorize/instrumentation.rb 3 additions, 7 deletionslib/gitlab/graphql/authorize/instrumentation.rb
- spec/graphql/features/authorization_spec.rb 106 additions, 0 deletionsspec/graphql/features/authorization_spec.rb
- spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb 18 additions, 0 deletionsspec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb
- spec/lib/gitlab/graphql/authorize_spec.rb 0 additions, 20 deletionsspec/lib/gitlab/graphql/authorize_spec.rb
- spec/support/matchers/graphql_matchers.rb 1 addition, 3 deletionsspec/support/matchers/graphql_matchers.rb
config/initializers/graphql.rb
0 → 100644
spec/graphql/features/authorization_spec.rb
0 → 100644
Please register or sign in to comment