From 1dab503bb9f723d12c944d23d0f7f8060378583b Mon Sep 17 00:00:00 2001 From: gearnode Date: Thu, 13 Mar 2025 07:45:01 +0100 Subject: [PATCH] Fix people selector stale state Signed-off-by: gearnode --- .../console/src/components/PeopleSelector.tsx | 3 +- .../PeopleSelector_organization.graphql.ts | 70 +++++++++++++--- apps/console/src/pages/CreatePeoplePage.tsx | 15 ++-- .../CreatePolicyPageQuery.graphql.ts | 84 ++++++++++++++----- .../UpdatePolicyPageQuery.graphql.ts | 67 ++++++++++++--- 5 files changed, 188 insertions(+), 51 deletions(-) diff --git a/apps/console/src/components/PeopleSelector.tsx b/apps/console/src/components/PeopleSelector.tsx index 5f309f903..385324269 100644 --- a/apps/console/src/components/PeopleSelector.tsx +++ b/apps/console/src/components/PeopleSelector.tsx @@ -12,7 +12,8 @@ import { PeopleSelector_organization$key } from "./__generated__/PeopleSelector_ const peopleSelectorFragment = graphql` fragment PeopleSelector_organization on Organization { id - peoples(first: 100) { + peoples(first: 100) + @connection(key: "PeopleSelector_organization_peoples") { edges { node { id diff --git a/apps/console/src/components/__generated__/PeopleSelector_organization.graphql.ts b/apps/console/src/components/__generated__/PeopleSelector_organization.graphql.ts index 64dd84c8c..d6a2d5e2c 100644 --- a/apps/console/src/components/__generated__/PeopleSelector_organization.graphql.ts +++ b/apps/console/src/components/__generated__/PeopleSelector_organization.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<40624c6362024ecac90d44c5dd174a1c>> + * @generated SignedSource<<78caa409132a5db72b83629bdcd023d5>> * @lightSyntaxTransform * @nogrep */ @@ -39,22 +39,27 @@ var v0 = { return { "argumentDefinitions": [], "kind": "Fragment", - "metadata": null, + "metadata": { + "connection": [ + { + "count": null, + "cursor": null, + "direction": "forward", + "path": [ + "peoples" + ] + } + ] + }, "name": "PeopleSelector_organization", "selections": [ (v0/*: any*/), { - "alias": null, - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 100 - } - ], + "alias": "peoples", + "args": null, "concreteType": "PeopleConnection", "kind": "LinkedField", - "name": "peoples", + "name": "__PeopleSelector_organization_peoples_connection", "plural": false, "selections": [ { @@ -87,15 +92,54 @@ return { "kind": "ScalarField", "name": "primaryEmailAddress", "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null } ], "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null } ], "storageKey": null } ], - "storageKey": "peoples(first:100)" + "storageKey": null } ], "type": "Organization", @@ -103,6 +147,6 @@ return { }; })(); -(node as any).hash = "33e28b2889fa1180f6bf491e428fbafd"; +(node as any).hash = "ed86f67795b049ec359cb7e5e55500a0"; export default node; diff --git a/apps/console/src/pages/CreatePeoplePage.tsx b/apps/console/src/pages/CreatePeoplePage.tsx index 7a87d7cc2..a99a81cfe 100644 --- a/apps/console/src/pages/CreatePeoplePage.tsx +++ b/apps/console/src/pages/CreatePeoplePage.tsx @@ -87,14 +87,19 @@ function CreatePeoplePageContent() { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - const peopleConnectionId = ConnectionHandler.getConnectionID( - organizationId!, - "PeopleListPage_peoples" - ); createPeople({ variables: { - connections: [peopleConnectionId], + connections: [ + ConnectionHandler.getConnectionID( + organizationId!, + "PeopleListPage_peoples" + ), + ConnectionHandler.getConnectionID( + organizationId!, + "PeopleSelector_organization_peoples" + ), + ], input: { organizationId: organizationId!, fullName: formData.fullName, diff --git a/apps/console/src/pages/__generated__/CreatePolicyPageQuery.graphql.ts b/apps/console/src/pages/__generated__/CreatePolicyPageQuery.graphql.ts index 17e305def..7203eb9ec 100644 --- a/apps/console/src/pages/__generated__/CreatePolicyPageQuery.graphql.ts +++ b/apps/console/src/pages/__generated__/CreatePolicyPageQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<0229a3e8e814cf3971479aa5abc20322>> + * @generated SignedSource<<8bfccae4e1629a74d3651300b7f45768>> * @lightSyntaxTransform * @nogrep */ @@ -39,12 +39,26 @@ v1 = [ } ], v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null +}, +v3 = { "alias": null, "args": null, "kind": "ScalarField", "name": "id", "storageKey": null -}; +}, +v4 = [ + { + "kind": "Literal", + "name": "first", + "value": 100 + } +]; return { "fragment": { "argumentDefinitions": (v0/*: any*/), @@ -86,26 +100,14 @@ return { "name": "node", "plural": false, "selections": [ - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__typename", - "storageKey": null - }, (v2/*: any*/), + (v3/*: any*/), { "kind": "InlineFragment", "selections": [ { "alias": null, - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 100 - } - ], + "args": (v4/*: any*/), "concreteType": "PeopleConnection", "kind": "LinkedField", "name": "peoples", @@ -127,7 +129,7 @@ return { "name": "node", "plural": false, "selections": [ - (v2/*: any*/), + (v3/*: any*/), { "alias": null, "args": null, @@ -141,15 +143,57 @@ return { "kind": "ScalarField", "name": "primaryEmailAddress", "storageKey": null - } + }, + (v2/*: any*/) ], "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null } ], "storageKey": null } ], "storageKey": "peoples(first:100)" + }, + { + "alias": null, + "args": (v4/*: any*/), + "filters": null, + "handle": "connection", + "key": "PeopleSelector_organization_peoples", + "kind": "LinkedHandle", + "name": "peoples" } ], "type": "Organization", @@ -161,12 +205,12 @@ return { ] }, "params": { - "cacheID": "edb18dbe0439fa7ca7bc791e607cd447", + "cacheID": "cb5621c91f5548cd81c31d40b51ac894", "id": null, "metadata": {}, "name": "CreatePolicyPageQuery", "operationKind": "query", - "text": "query CreatePolicyPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ...PeopleSelector_organization\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n" + "text": "query CreatePolicyPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ...PeopleSelector_organization\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n" } }; })(); diff --git a/apps/console/src/pages/__generated__/UpdatePolicyPageQuery.graphql.ts b/apps/console/src/pages/__generated__/UpdatePolicyPageQuery.graphql.ts index da7be263d..726960d30 100644 --- a/apps/console/src/pages/__generated__/UpdatePolicyPageQuery.graphql.ts +++ b/apps/console/src/pages/__generated__/UpdatePolicyPageQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<04e2a37d31d4cd204101efdd85471dc5>> + * @generated SignedSource<<7b013568b7e507b2394323b6cdc4d8ba>> * @lightSyntaxTransform * @nogrep */ @@ -137,7 +137,14 @@ v7 = { "kind": "ScalarField", "name": "__typename", "storageKey": null -}; +}, +v8 = [ + { + "kind": "Literal", + "name": "first", + "value": 100 + } +]; return { "fragment": { "argumentDefinitions": [ @@ -219,13 +226,7 @@ return { "selections": [ { "alias": null, - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 100 - } - ], + "args": (v8/*: any*/), "concreteType": "PeopleConnection", "kind": "LinkedField", "name": "peoples", @@ -255,15 +256,57 @@ return { "kind": "ScalarField", "name": "primaryEmailAddress", "storageKey": null - } + }, + (v7/*: any*/) ], "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null } ], "storageKey": null } ], "storageKey": "peoples(first:100)" + }, + { + "alias": null, + "args": (v8/*: any*/), + "filters": null, + "handle": "connection", + "key": "PeopleSelector_organization_peoples", + "kind": "LinkedHandle", + "name": "peoples" } ], "type": "Organization", @@ -275,12 +318,12 @@ return { ] }, "params": { - "cacheID": "abbd1265e5fbacc34d5442772cbd645b", + "cacheID": "48cf7497849c327c91bff96c755645eb", "id": null, "metadata": {}, "name": "UpdatePolicyPageQuery", "operationKind": "query", - "text": "query UpdatePolicyPageQuery(\n $policyId: ID!\n $organizationId: ID!\n) {\n policy: node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n status\n version\n reviewDate\n owner {\n id\n fullName\n }\n }\n }\n organization: node(id: $organizationId) {\n __typename\n ...PeopleSelector_organization\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n }\n }\n }\n}\n" + "text": "query UpdatePolicyPageQuery(\n $policyId: ID!\n $organizationId: ID!\n) {\n policy: node(id: $policyId) {\n __typename\n id\n ... on Policy {\n name\n content\n status\n version\n reviewDate\n owner {\n id\n fullName\n }\n }\n }\n organization: node(id: $organizationId) {\n __typename\n ...PeopleSelector_organization\n id\n }\n}\n\nfragment PeopleSelector_organization on Organization {\n id\n peoples(first: 100) {\n edges {\n node {\n id\n fullName\n primaryEmailAddress\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n" } }; })();