From 04a4584f7477748da5134e51ed5189a00fbed247 Mon Sep 17 00:00:00 2001 From: Kevin Kandlbinder Date: Wed, 7 Sep 2022 18:57:48 +0200 Subject: [PATCH] backend: Make subscribedLists field nullable --- graph/generated/generated.go | 24 ++----------------- graph/schema.graphqls | 2 +- webui/data/schema.graphql | 2 +- .../src/components/panel/rooms/RoomDetail.tsx | 12 +++++----- .../__generated__/RoomDetailQuery.graphql.ts | 4 ++-- .../ReconfigureRoomMutation.graphql.ts | 4 ++-- 6 files changed, 14 insertions(+), 34 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index c0d20b4..f074664 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -1090,7 +1090,7 @@ enum HashCheckerMode { type HashCheckerConfig { chatNotice: Boolean! hashCheckMode: HashCheckerMode! - subscribedLists(first: Int, after: String): ListConnection! + subscribedLists(first: Int, after: String): ListConnection } type Room { @@ -3077,14 +3077,11 @@ func (ec *executionContext) _HashCheckerConfig_subscribedLists(ctx context.Conte return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*model.ListConnection) fc.Result = res - return ec.marshalNListConnection2ᚖgithubᚗcomᚋUnkn0wnCatᚋmatrixᚑvelesᚋgraphᚋmodelᚐListConnection(ctx, field.Selections, res) + return ec.marshalOListConnection2ᚖgithubᚗcomᚋUnkn0wnCatᚋmatrixᚑvelesᚋgraphᚋmodelᚐListConnection(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_HashCheckerConfig_subscribedLists(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -10296,9 +10293,6 @@ func (ec *executionContext) _HashCheckerConfig(ctx context.Context, sel ast.Sele } }() res = ec._HashCheckerConfig_subscribedLists(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } return res } @@ -11782,20 +11776,6 @@ func (ec *executionContext) marshalNList2ᚖgithubᚗcomᚋUnkn0wnCatᚋmatrix return ec._List(ctx, sel, v) } -func (ec *executionContext) marshalNListConnection2githubᚗcomᚋUnkn0wnCatᚋmatrixᚑvelesᚋgraphᚋmodelᚐListConnection(ctx context.Context, sel ast.SelectionSet, v model.ListConnection) graphql.Marshaler { - return ec._ListConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNListConnection2ᚖgithubᚗcomᚋUnkn0wnCatᚋmatrixᚑvelesᚋgraphᚋmodelᚐListConnection(ctx context.Context, sel ast.SelectionSet, v *model.ListConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._ListConnection(ctx, sel, v) -} - func (ec *executionContext) marshalNListEdge2ᚕᚖgithubᚗcomᚋUnkn0wnCatᚋmatrixᚑvelesᚋgraphᚋmodelᚐListEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.ListEdge) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/graph/schema.graphqls b/graph/schema.graphqls index a551fca..03d56c6 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -40,7 +40,7 @@ enum HashCheckerMode { type HashCheckerConfig { chatNotice: Boolean! hashCheckMode: HashCheckerMode! - subscribedLists(first: Int, after: String): ListConnection! + subscribedLists(first: Int, after: String): ListConnection } type Room { diff --git a/webui/data/schema.graphql b/webui/data/schema.graphql index a551fca..03d56c6 100644 --- a/webui/data/schema.graphql +++ b/webui/data/schema.graphql @@ -40,7 +40,7 @@ enum HashCheckerMode { type HashCheckerConfig { chatNotice: Boolean! hashCheckMode: HashCheckerMode! - subscribedLists(first: Int, after: String): ListConnection! + subscribedLists(first: Int, after: String): ListConnection } type Room { diff --git a/webui/src/components/panel/rooms/RoomDetail.tsx b/webui/src/components/panel/rooms/RoomDetail.tsx index 7777670..70f2436 100644 --- a/webui/src/components/panel/rooms/RoomDetail.tsx +++ b/webui/src/components/panel/rooms/RoomDetail.tsx @@ -67,7 +67,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { reconfigureRoom({ variables: { reconfigureInput: { - id: data.room?.id!, + id: data.room!.id!, deactivate: !ev.currentTarget.checked } } @@ -78,7 +78,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { reconfigureRoom({ variables: { reconfigureInput: { - id: data.room?.id!, + id: data.room!.id!, debug: ev.currentTarget.checked } } @@ -103,7 +103,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { reconfigureRoom({ variables: { reconfigureInput: { - id: data.room?.id!, + id: data.room!.id!, adminPowerLevel: newAdminPowerLevel } } @@ -120,7 +120,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { reconfigureRoom({ variables: { reconfigureInput: { - id: data.room?.id!, + id: data.room!.id!, hashChecker: { chatNotice: ev.currentTarget.checked } @@ -134,7 +134,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { reconfigureRoom({ variables: { reconfigureInput: { - id: data.room?.id!, + id: data.room!.id!, hashChecker: { hashCheckMode: ev.currentTarget.value as HashCheckerMode } @@ -159,7 +159,7 @@ const RoomDetailInner = ({initialQueryRef}: PropsFinal) => { { - data.room?.hashCheckerConfig.subscribedLists.edges.map((edge) => { + data.room?.hashCheckerConfig.subscribedLists?.edges.map((edge) => { return {navigate("/hashing/lists/"+edge.node.id)}} key={edge.node.id}> {edge.node.name} {edge.node.id} diff --git a/webui/src/components/panel/rooms/__generated__/RoomDetailQuery.graphql.ts b/webui/src/components/panel/rooms/__generated__/RoomDetailQuery.graphql.ts index e27e675..416577c 100644 --- a/webui/src/components/panel/rooms/__generated__/RoomDetailQuery.graphql.ts +++ b/webui/src/components/panel/rooms/__generated__/RoomDetailQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<1663469824a6a66c6959a37976f2a05e>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -32,7 +32,7 @@ export type RoomDetailQuery$data = { readonly name: string; }; }>; - }; + } | null; }; } | null; }; diff --git a/webui/src/mutations/__generated__/ReconfigureRoomMutation.graphql.ts b/webui/src/mutations/__generated__/ReconfigureRoomMutation.graphql.ts index 4869424..7e91f0a 100644 --- a/webui/src/mutations/__generated__/ReconfigureRoomMutation.graphql.ts +++ b/webui/src/mutations/__generated__/ReconfigureRoomMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<0e26637d8a4933e2cfcb7d11667fc67c>> * @lightSyntaxTransform * @nogrep */ @@ -44,7 +44,7 @@ export type ReconfigureRoomMutation$data = { readonly tags: ReadonlyArray | null; }; }>; - }; + } | null; }; }; };