Commit 86b0a8c9 authored by Mario Celi's avatar Mario Celi

Allow GraphQL MemberInterface to support null users

MemberInterface had not null set for the `user` field.
This would cause an error in the query when there are members
invited only via email in the list.

Changelog: fixed
parent 7b06f6bc
......@@ -22,7 +22,7 @@ module Types
field :expires_at, Types::TimeType, null: true,
description: 'Date and time the membership expires.'
field :user, Types::UserType, null: false,
field :user, Types::UserType, null: true,
description: 'User that is associated with the member object.'
definition_methods do
......
......@@ -9500,7 +9500,7 @@ Represents a Group Membership.
| <a id="groupmembergroup"></a>`group` | [`Group`](#group) | Group that a User is a member of. |
| <a id="groupmemberid"></a>`id` | [`ID!`](#id) | ID of the member. |
| <a id="groupmemberupdatedat"></a>`updatedAt` | [`Time`](#time) | Date and time the membership was last updated. |
| <a id="groupmemberuser"></a>`user` | [`UserCore!`](#usercore) | User that is associated with the member object. |
| <a id="groupmemberuser"></a>`user` | [`UserCore`](#usercore) | User that is associated with the member object. |
| <a id="groupmemberuserpermissions"></a>`userPermissions` | [`GroupPermissions!`](#grouppermissions) | Permissions for the current user on the resource. |
### `GroupPermissions`
......@@ -11915,7 +11915,7 @@ Represents a Project Membership.
| <a id="projectmemberid"></a>`id` | [`ID!`](#id) | ID of the member. |
| <a id="projectmemberproject"></a>`project` | [`Project`](#project) | Project that User is a member of. |
| <a id="projectmemberupdatedat"></a>`updatedAt` | [`Time`](#time) | Date and time the membership was last updated. |
| <a id="projectmemberuser"></a>`user` | [`UserCore!`](#usercore) | User that is associated with the member object. |
| <a id="projectmemberuser"></a>`user` | [`UserCore`](#usercore) | User that is associated with the member object. |
| <a id="projectmemberuserpermissions"></a>`userPermissions` | [`ProjectPermissions!`](#projectpermissions) | Permissions for the current user on the resource. |
### `ProjectPermissions`
......@@ -15686,7 +15686,7 @@ Implementations:
| <a id="memberinterfaceexpiresat"></a>`expiresAt` | [`Time`](#time) | Date and time the membership expires. |
| <a id="memberinterfaceid"></a>`id` | [`ID!`](#id) | ID of the member. |
| <a id="memberinterfaceupdatedat"></a>`updatedAt` | [`Time`](#time) | Date and time the membership was last updated. |
| <a id="memberinterfaceuser"></a>`user` | [`UserCore!`](#usercore) | User that is associated with the member object. |
| <a id="memberinterfaceuser"></a>`user` | [`UserCore`](#usercore) | User that is associated with the member object. |
#### `Noteable`
......
......@@ -14,6 +14,23 @@ RSpec.describe 'getting group members information' do
[user_1, user_2].each { |user| parent_group.add_guest(user) }
end
context 'when a member is invited only via email' do
before do
create(:group_member, :invited, source: parent_group)
end
it 'returns null in the user field' do
fetch_members(group: parent_group, args: { relations: [:DIRECT] })
expect(graphql_errors).to be_nil
expect(graphql_data_at(:group, :group_members, :edges, :node)).to contain_exactly(
{ 'user' => { 'id' => global_id_of(user_1) } },
{ 'user' => { 'id' => global_id_of(user_2) } },
'user' => nil
)
end
end
context 'when the request is correct' do
it_behaves_like 'a working graphql query' do
before do
......
......@@ -50,6 +50,20 @@ RSpec.describe 'getting project members information' do
invited_group.add_guest(invited_user)
end
context 'when a member is invited only via email and current_user is a maintainer' do
before do
parent_project.add_maintainer(user)
create(:project_member, :invited, source: parent_project)
end
it 'returns null in the user field' do
fetch_members(project: parent_project, args: { relations: [:DIRECT] })
expect(graphql_errors).to be_nil
expect(graphql_data_at(:project, :project_members, :edges, :node)).to contain_exactly({ 'user' => { 'id' => global_id_of(user) } }, 'user' => nil)
end
end
it 'returns direct members' do
fetch_members(project: child_project, args: { relations: [:DIRECT] })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment