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
显示
- app/graphql/types/issue_type.rb 4 个添加, 6 个删除app/graphql/types/issue_type.rb
- app/graphql/types/merge_request_type.rb 1 个添加, 3 个删除app/graphql/types/merge_request_type.rb
- app/graphql/types/project_type.rb 4 个添加, 6 个删除app/graphql/types/project_type.rb
- app/graphql/types/query_type.rb 2 个添加, 3 个删除app/graphql/types/query_type.rb
- config/initializers/graphql.rb 4 个添加, 0 个删除config/initializers/graphql.rb
- doc/development/api_graphql_styleguide.md 17 个添加, 7 个删除doc/development/api_graphql_styleguide.md
- lib/gitlab/graphql/authorize.rb 0 个添加, 15 个删除lib/gitlab/graphql/authorize.rb
- lib/gitlab/graphql/authorize/authorize_resource.rb 15 个添加, 2 个删除lib/gitlab/graphql/authorize/authorize_resource.rb
- lib/gitlab/graphql/authorize/instrumentation.rb 3 个添加, 7 个删除lib/gitlab/graphql/authorize/instrumentation.rb
- spec/graphql/features/authorization_spec.rb 106 个添加, 0 个删除spec/graphql/features/authorization_spec.rb
- spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb 18 个添加, 0 个删除spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb
- spec/lib/gitlab/graphql/authorize_spec.rb 0 个添加, 20 个删除spec/lib/gitlab/graphql/authorize_spec.rb
- spec/support/matchers/graphql_matchers.rb 1 个添加, 3 个删除spec/support/matchers/graphql_matchers.rb
加载中
想要评论请 注册 或 登录