Skip to content

Commit c9004fd

Browse files
authored
Merge pull request #10929 from neinteractiveliterature/fix-become-user-permissions-error
Fix "An object of type EventProposal" error
2 parents 8215b0b + b2040ad commit c9004fd

4 files changed

Lines changed: 79 additions & 20 deletions

File tree

app/graphql/types/user_type.rb

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
# frozen_string_literal: true
22
class Types::UserType < Types::BaseObject
3+
description <<~MARKDOWN
4+
A user on this instance of Intercode. Users exist across all conventions. For each convention a user has logged
5+
into, they will have an attached UserConProfile.
6+
MARKDOWN
7+
38
authorize_record
49

5-
field :email, String, null: true
6-
field :event_proposals, [Types::EventProposalType], null: false
7-
field :first_name, String, null: true
8-
field :id, ID, null: false
9-
field :last_name, String, null: true
10-
field :name, String, null: true
11-
field :name_inverted, String, null: true
12-
field :privileges, [String], null: true
13-
field :user_con_profiles, [Types::UserConProfileType], null: false
10+
field :email, String, null: true, description: "The user's email address"
11+
field :event_proposals, [Types::EventProposalType], null: false, description: "The event proposals owned by this user"
12+
field :first_name, String, null: true, description: "The user's first name"
13+
field :id, ID, null: false, description: "The unique ID of this user"
14+
field :last_name, String, null: true, description: "The user's last name"
15+
field :name, String, null: true, description: "The user's full name"
16+
field :name_inverted, String, null: true, description: "The user's full name in Last, First format"
17+
field :privileges, [String], null: true, description: "The global privileges this user has across all conventions"
18+
field :user_con_profiles, [Types::UserConProfileType], null: false do
19+
description "All of the UserConProfiles owned by this user"
20+
end
1421

1522
association_loaders User, :user_con_profiles
1623

@@ -20,6 +27,6 @@ def event_proposals
2027
# avoid n+1 in the policy check
2128
::ActiveRecord::Associations::Preloader.new(records: event_proposals, associations: :owner).call
2229

23-
event_proposals
30+
event_proposals.select { |p| policy(p).read? }
2431
end
2532
end

app/javascript/graphqlTypes.generated.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6821,16 +6821,29 @@ export type UpdateUserConProfilePayload = {
68216821
user_con_profile: UserConProfile;
68226822
};
68236823

6824+
/**
6825+
* A user on this instance of Intercode. Users exist across all conventions. For each convention a user has logged
6826+
* into, they will have an attached UserConProfile.
6827+
*/
68246828
export type User = {
68256829
__typename: 'User';
6830+
/** The user's email address */
68266831
email?: Maybe<Scalars['String']['output']>;
6832+
/** The event proposals owned by this user */
68276833
event_proposals: Array<EventProposal>;
6834+
/** The user's first name */
68286835
first_name?: Maybe<Scalars['String']['output']>;
6836+
/** The unique ID of this user */
68296837
id: Scalars['ID']['output'];
6838+
/** The user's last name */
68306839
last_name?: Maybe<Scalars['String']['output']>;
6840+
/** The user's full name */
68316841
name?: Maybe<Scalars['String']['output']>;
6842+
/** The user's full name in Last, First format */
68326843
name_inverted?: Maybe<Scalars['String']['output']>;
6844+
/** The global privileges this user has across all conventions */
68336845
privileges?: Maybe<Array<Scalars['String']['output']>>;
6846+
/** All of the UserConProfiles owned by this user */
68346847
user_con_profiles: Array<UserConProfile>;
68356848
};
68366849

schema.graphql

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8888,15 +8888,54 @@ type UpdateUserConProfilePayload {
88888888

88898889
scalar Upload
88908890

8891+
"""
8892+
A user on this instance of Intercode. Users exist across all conventions. For each convention a user has logged
8893+
into, they will have an attached UserConProfile.
8894+
"""
88918895
type User {
8896+
"""
8897+
The user's email address
8898+
"""
88928899
email: String
8900+
8901+
"""
8902+
The event proposals owned by this user
8903+
"""
88938904
event_proposals: [EventProposal!]!
8905+
8906+
"""
8907+
The user's first name
8908+
"""
88948909
first_name: String
8910+
8911+
"""
8912+
The unique ID of this user
8913+
"""
88958914
id: ID!
8915+
8916+
"""
8917+
The user's last name
8918+
"""
88968919
last_name: String
8920+
8921+
"""
8922+
The user's full name
8923+
"""
88978924
name: String
8925+
8926+
"""
8927+
The user's full name in Last, First format
8928+
"""
88988929
name_inverted: String
8930+
8931+
"""
8932+
The global privileges this user has across all conventions
8933+
"""
88998934
privileges: [String!]
8935+
8936+
"""
8937+
All of the UserConProfiles owned by this user
8938+
"""
89008939
user_con_profiles: [UserConProfile!]!
89018940
}
89028941

schema.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39226,13 +39226,13 @@
3922639226
{
3922739227
"kind": "OBJECT",
3922839228
"name": "User",
39229-
"description": null,
39229+
"description": "A user on this instance of Intercode. Users exist across all conventions. For each convention a user has logged\ninto, they will have an attached UserConProfile.\n",
3923039230
"interfaces": [],
3923139231
"possibleTypes": null,
3923239232
"fields": [
3923339233
{
3923439234
"name": "email",
39235-
"description": null,
39235+
"description": "The user's email address",
3923639236
"type": {
3923739237
"kind": "SCALAR",
3923839238
"name": "String",
@@ -39244,7 +39244,7 @@
3924439244
},
3924539245
{
3924639246
"name": "event_proposals",
39247-
"description": null,
39247+
"description": "The event proposals owned by this user",
3924839248
"type": {
3924939249
"kind": "NON_NULL",
3925039250
"name": null,
@@ -39268,7 +39268,7 @@
3926839268
},
3926939269
{
3927039270
"name": "first_name",
39271-
"description": null,
39271+
"description": "The user's first name",
3927239272
"type": {
3927339273
"kind": "SCALAR",
3927439274
"name": "String",
@@ -39280,7 +39280,7 @@
3928039280
},
3928139281
{
3928239282
"name": "id",
39283-
"description": null,
39283+
"description": "The unique ID of this user",
3928439284
"type": {
3928539285
"kind": "NON_NULL",
3928639286
"name": null,
@@ -39296,7 +39296,7 @@
3929639296
},
3929739297
{
3929839298
"name": "last_name",
39299-
"description": null,
39299+
"description": "The user's last name",
3930039300
"type": {
3930139301
"kind": "SCALAR",
3930239302
"name": "String",
@@ -39308,7 +39308,7 @@
3930839308
},
3930939309
{
3931039310
"name": "name",
39311-
"description": null,
39311+
"description": "The user's full name",
3931239312
"type": {
3931339313
"kind": "SCALAR",
3931439314
"name": "String",
@@ -39320,7 +39320,7 @@
3932039320
},
3932139321
{
3932239322
"name": "name_inverted",
39323-
"description": null,
39323+
"description": "The user's full name in Last, First format",
3932439324
"type": {
3932539325
"kind": "SCALAR",
3932639326
"name": "String",
@@ -39332,7 +39332,7 @@
3933239332
},
3933339333
{
3933439334
"name": "privileges",
39335-
"description": null,
39335+
"description": "The global privileges this user has across all conventions",
3933639336
"type": {
3933739337
"kind": "LIST",
3933839338
"name": null,
@@ -39352,7 +39352,7 @@
3935239352
},
3935339353
{
3935439354
"name": "user_con_profiles",
39355-
"description": null,
39355+
"description": "All of the UserConProfiles owned by this user",
3935639356
"type": {
3935739357
"kind": "NON_NULL",
3935839358
"name": null,

0 commit comments

Comments
 (0)