From eb2b7e7abe76d449aefbd453fffa5936c5961b8f Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:03:28 +0200 Subject: [PATCH 1/9] Update registration mutation It is updated due to engine breaking changes. --- src/templates/snek/gql/mutations/user.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/templates/snek/gql/mutations/user.ts b/src/templates/snek/gql/mutations/user.ts index bde8128..45132fc 100644 --- a/src/templates/snek/gql/mutations/user.ts +++ b/src/templates/snek/gql/mutations/user.ts @@ -17,16 +17,17 @@ import gql from "graphql-tag"; */ const registration = gql` mutation registration($token: String!, $values: GenericScalar!) { - registration: registrationFormPage( - url: "/registration/", - token: $token, - values: $values) { - result - errors { - name - errors - } + registration: personRegistrationFormPage( + url: "/person-registration-form/" + token: $token + values: $values + ) { + result + errors { + name + errors } + } } `; @@ -40,8 +41,8 @@ const registration = gql` * @description A mutation to cache user information server side */ const cache = gql` - mutation cache($token: String!, $platformData: String!) { - cache: cacheUser(token: $token, platformData: $platformData) { + mutation cache($token: String!, $cache: String!) { + cache: cacheUser(token: $token, cache: $cache) { user { id } From 2a740a5a7b2e6632bb604612cbbce87e8e27afad Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:04:07 +0200 Subject: [PATCH 2/9] Update cache mutation It is updated due to engine breaking changes. --- src/templates/snek/gql/tasks/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index cc33c18..1b1f21a 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -87,16 +87,16 @@ class SnekGqlUserTasks { /** * Cache a user. * - * @param {string} platformData A serialized JSON object to be cached + * @param {string} cache A serialized JSON object to be cached * @returns {Promise>} Cache data */ - async cache(platformData: string): Promise> { + async cache(cache: string): Promise> { const response = await this.parent.run( "mutation", this.parent.template.mutations.user.cache, { token: await this.parent.session.upToDateToken(), - platformData, + cache, } ); From b9402d68872e8ba3e25010ebbe98e8bf12c0dcaf Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:05:10 +0200 Subject: [PATCH 3/9] Update gitlabserver query It is updated due to engine breaking changes. --- src/templates/snek/gql/queries/general.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/snek/gql/queries/general.ts b/src/templates/snek/gql/queries/general.ts index d11b3e5..ba7459e 100644 --- a/src/templates/snek/gql/queries/general.ts +++ b/src/templates/snek/gql/queries/general.ts @@ -15,10 +15,10 @@ import gql from "graphql-tag"; */ const gitlabServer = gql` query gitLabServers($token: String!) { - page(slug: "registration", token: $token) { - ... on RegistrationFormPage { + page(slug: "person-registration-form", token: $token) { + ... on PersonRegistrationFormPage { supportedGitlabs { - ... on Gitlab_Server { + ... on GitlabServer { id organisation domain From f1260026b16137c38c4e7a0e38581ba24dadae18 Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:05:30 +0200 Subject: [PATCH 4/9] Update alluserpages query It is updated due to engine breaking changes. --- src/templates/snek/gql/queries/general.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/snek/gql/queries/general.ts b/src/templates/snek/gql/queries/general.ts index ba7459e..37eff20 100644 --- a/src/templates/snek/gql/queries/general.ts +++ b/src/templates/snek/gql/queries/general.ts @@ -53,7 +53,7 @@ const allPageUrls = gql` */ const allUserPageUrls = gql` query userPages($token: String!) { - page(slug: "user", token: $token) { + page(slug: "people", token: $token) { children { slug title From 8a28068a7718d30188e5119f4a352123fb3583c4 Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:05:49 +0200 Subject: [PATCH 5/9] Update profile query It is updated due to engine breaking changes. --- src/templates/snek/gql/queries/user.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/templates/snek/gql/queries/user.ts b/src/templates/snek/gql/queries/user.ts index d1b6f8a..0637899 100644 --- a/src/templates/snek/gql/queries/user.ts +++ b/src/templates/snek/gql/queries/user.ts @@ -30,19 +30,20 @@ const whoami = gql` * @description A query to fetch profile data */ const profile = gql` - query profile($slug: String!, $token: String!) { - profile: page(slug: $slug, token: $token) { - ... on ProfilePage { - username - firstName - lastName - email - verified - platformData - sources - bids + query profile($username: String!, $token: String!) { + profile: user(username: $username, token: $token) { + username + firstName + lastName + email + verified: isActive + personpage { + title tids + bids } + platformData: cache + sources } } `; From c73ba3a20741c1c53c2f3b939499a87ae8fd5d49 Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 12 Aug 2020 15:06:18 +0200 Subject: [PATCH 6/9] Update profile task The task is updated due to changes in the profile query. --- src/templates/snek/gql/tasks/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index 1b1f21a..a59d415 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -106,15 +106,15 @@ class SnekGqlUserTasks { /** * Get profile. * - * @param {string} slug Slug: > + * @param {string} username Username: * @returns {Promise>} The profile page of a user */ - async profile(slug: string): Promise> { + async profile(username: string): Promise> { const response = await this.parent.run( "query", this.parent.template.queries.user.profile, { - slug, + username, token: await this.parent.session.upToDateToken(), } ); From 37b77da5c9f8bc037c58fa1bb623532986292cef Mon Sep 17 00:00:00 2001 From: schettn Date: Mon, 24 Aug 2020 18:08:24 +0200 Subject: [PATCH 7/9] Update profile query and task Once again, the profile query and task have been updated due to a structure change in engine. --- src/templates/snek/gql/queries/user.ts | 47 +++++++++++++++++++------- src/templates/snek/gql/tasks/user.ts | 34 ++++++++++++++++--- 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/templates/snek/gql/queries/user.ts b/src/templates/snek/gql/queries/user.ts index 0637899..2b680c1 100644 --- a/src/templates/snek/gql/queries/user.ts +++ b/src/templates/snek/gql/queries/user.ts @@ -24,26 +24,49 @@ const whoami = gql` /** * Get user profile. * - * @param {string} slug Slug: > + * @param {string} slug Slug: > * @param {string} token A users JWT * @returns {string} A profile page of a user * @description A query to fetch profile data */ const profile = gql` - query profile($username: String!, $token: String!) { - profile: user(username: $username, token: $token) { - username - firstName - lastName - email - verified: isActive - personpage { - title + query profile($slug: String!, $token: String!) { + page(slug: $slug, token: $token) { + ... on PersonFormPage { + personName: title + firstName + lastName + email + platformData: cache + sources + person { + cache + sources + } tids bids + follows { + personName: slug + } + followedBy { + personName: slug + } + likes { + personName: slug + } + likedBy { + personName: slug + } + achievements { + id + title + image { + src + imageSourceUrl + } + points + } } - platformData: cache - sources } } `; diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index a59d415..51ac9ad 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -32,15 +32,39 @@ interface CacheData { */ interface ProfileData { profile: { - username: string; + profileName: string; firstName: string; lastName: string; email: string; - verified: string; platformData: string; sources: string; bids: string; tids: string; + person: { + cache: string; + sources: string; + }; + follows: { + personName: string; + }[]; + followedBy: { + personName: string; + }[]; + likes: { + personName: string; + }[]; + likedBy: { + personName: string; + }[]; + achievements: { + id: string; + title: string; + image: { + src: string; + imageSourceUrl: string; + }; + points: string; + }; }; } @@ -106,15 +130,15 @@ class SnekGqlUserTasks { /** * Get profile. * - * @param {string} username Username: + * @param {string} slug Slug: > * @returns {Promise>} The profile page of a user */ - async profile(username: string): Promise> { + async profile(slug: string): Promise> { const response = await this.parent.run( "query", this.parent.template.queries.user.profile, { - username, + slug, token: await this.parent.session.upToDateToken(), } ); From f07745088c82567166416b8f3c1218b78b2c099a Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 26 Aug 2020 11:42:40 +0200 Subject: [PATCH 8/9] Improve profile task The person task no longer accepts a slug but a personName. --- src/templates/snek/gql/tasks/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index 51ac9ad..2a0cca0 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -130,15 +130,15 @@ class SnekGqlUserTasks { /** * Get profile. * - * @param {string} slug Slug: > + * @param {string} personName personName: * @returns {Promise>} The profile page of a user */ - async profile(slug: string): Promise> { + async profile(personName: string): Promise> { const response = await this.parent.run( "query", this.parent.template.queries.user.profile, { - slug, + slug: `p-${personName}`, token: await this.parent.session.upToDateToken(), } ); From 214ca592c8d469660251487ce3a95e265234fbc8 Mon Sep 17 00:00:00 2001 From: schettn Date: Wed, 26 Aug 2020 15:38:46 +0200 Subject: [PATCH 9/9] Update cache mutation and task The cacheing task requires a person name now. --- src/templates/snek/gql/mutations/user.ts | 6 +++--- src/templates/snek/gql/tasks/user.ts | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/templates/snek/gql/mutations/user.ts b/src/templates/snek/gql/mutations/user.ts index 45132fc..7e5f9a1 100644 --- a/src/templates/snek/gql/mutations/user.ts +++ b/src/templates/snek/gql/mutations/user.ts @@ -41,9 +41,9 @@ const registration = gql` * @description A mutation to cache user information server side */ const cache = gql` - mutation cache($token: String!, $cache: String!) { - cache: cacheUser(token: $token, cache: $cache) { - user { + mutation cache($token: String!, $personName: String!, $cache: String!) { + cache: cacheUser(token: $token, personName: $personName, cache: $cache) { + personPage { id } } diff --git a/src/templates/snek/gql/tasks/user.ts b/src/templates/snek/gql/tasks/user.ts index 2a0cca0..e61d32e 100644 --- a/src/templates/snek/gql/tasks/user.ts +++ b/src/templates/snek/gql/tasks/user.ts @@ -111,15 +111,20 @@ class SnekGqlUserTasks { /** * Cache a user. * + * @param {string} personName The name of a users person page * @param {string} cache A serialized JSON object to be cached * @returns {Promise>} Cache data */ - async cache(cache: string): Promise> { + async cache( + personName: string, + cache: string + ): Promise> { const response = await this.parent.run( "mutation", this.parent.template.mutations.user.cache, { token: await this.parent.session.upToDateToken(), + personName, cache, } );