Skip to content

Commit f5aa706

Browse files
authored
Merge pull request #66 from snek-at/update-snekset-ba1
Update snekset ba1 to implement 2 (Migrate: Latest Sub Version 01.09.2020)
2 parents 115b57e + 214ca59 commit f5aa706

File tree

4 files changed

+85
-31
lines changed

4 files changed

+85
-31
lines changed

src/templates/snek/gql/mutations/user.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ import gql from "graphql-tag";
1717
*/
1818
const registration = gql`
1919
mutation registration($token: String!, $values: GenericScalar!) {
20-
registration: registrationFormPage(
21-
url: "/registration/",
22-
token: $token,
23-
values: $values) {
24-
result
25-
errors {
26-
name
27-
errors
28-
}
20+
registration: personRegistrationFormPage(
21+
url: "/person-registration-form/"
22+
token: $token
23+
values: $values
24+
) {
25+
result
26+
errors {
27+
name
28+
errors
2929
}
30+
}
3031
}
3132
`;
3233

@@ -40,9 +41,9 @@ const registration = gql`
4041
* @description A mutation to cache user information server side
4142
*/
4243
const cache = gql`
43-
mutation cache($token: String!, $platformData: String!) {
44-
cache: cacheUser(token: $token, platformData: $platformData) {
45-
user {
44+
mutation cache($token: String!, $personName: String!, $cache: String!) {
45+
cache: cacheUser(token: $token, personName: $personName, cache: $cache) {
46+
personPage {
4647
id
4748
}
4849
}

src/templates/snek/gql/queries/general.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import gql from "graphql-tag";
1515
*/
1616
const gitlabServer = gql`
1717
query gitLabServers($token: String!) {
18-
page(slug: "registration", token: $token) {
19-
... on RegistrationFormPage {
18+
page(slug: "person-registration-form", token: $token) {
19+
... on PersonRegistrationFormPage {
2020
supportedGitlabs {
21-
... on Gitlab_Server {
21+
... on GitlabServer {
2222
id
2323
organisation
2424
domain
@@ -53,7 +53,7 @@ const allPageUrls = gql`
5353
*/
5454
const allUserPageUrls = gql`
5555
query userPages($token: String!) {
56-
page(slug: "user", token: $token) {
56+
page(slug: "people", token: $token) {
5757
children {
5858
slug
5959
title

src/templates/snek/gql/queries/user.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,48 @@ const whoami = gql`
2424
/**
2525
* Get user profile.
2626
*
27-
* @param {string} slug Slug: <user_<username>>
27+
* @param {string} slug Slug: <p-<personName>>
2828
* @param {string} token A users JWT
2929
* @returns {string} A profile page of a user
3030
* @description A query to fetch profile data
3131
*/
3232
const profile = gql`
3333
query profile($slug: String!, $token: String!) {
34-
profile: page(slug: $slug, token: $token) {
35-
... on ProfilePage {
36-
username
34+
page(slug: $slug, token: $token) {
35+
... on PersonFormPage {
36+
personName: title
3737
firstName
3838
lastName
3939
email
40-
verified
41-
platformData
40+
platformData: cache
4241
sources
43-
bids
42+
person {
43+
cache
44+
sources
45+
}
4446
tids
47+
bids
48+
follows {
49+
personName: slug
50+
}
51+
followedBy {
52+
personName: slug
53+
}
54+
likes {
55+
personName: slug
56+
}
57+
likedBy {
58+
personName: slug
59+
}
60+
achievements {
61+
id
62+
title
63+
image {
64+
src
65+
imageSourceUrl
66+
}
67+
points
68+
}
4569
}
4670
}
4771
}

src/templates/snek/gql/tasks/user.ts

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,39 @@ interface CacheData {
3232
*/
3333
interface ProfileData {
3434
profile: {
35-
username: string;
35+
profileName: string;
3636
firstName: string;
3737
lastName: string;
3838
email: string;
39-
verified: string;
4039
platformData: string;
4140
sources: string;
4241
bids: string;
4342
tids: string;
43+
person: {
44+
cache: string;
45+
sources: string;
46+
};
47+
follows: {
48+
personName: string;
49+
}[];
50+
followedBy: {
51+
personName: string;
52+
}[];
53+
likes: {
54+
personName: string;
55+
}[];
56+
likedBy: {
57+
personName: string;
58+
}[];
59+
achievements: {
60+
id: string;
61+
title: string;
62+
image: {
63+
src: string;
64+
imageSourceUrl: string;
65+
};
66+
points: string;
67+
};
4468
};
4569
}
4670

@@ -87,16 +111,21 @@ class SnekGqlUserTasks {
87111
/**
88112
* Cache a user.
89113
*
90-
* @param {string} platformData A serialized JSON object to be cached
114+
* @param {string} personName The name of a users person page
115+
* @param {string} cache A serialized JSON object to be cached
91116
* @returns {Promise<ApolloResult<CacheData>>} Cache data
92117
*/
93-
async cache(platformData: string): Promise<ApolloResult<CacheData>> {
118+
async cache(
119+
personName: string,
120+
cache: string
121+
): Promise<ApolloResult<CacheData>> {
94122
const response = await this.parent.run<CacheData>(
95123
"mutation",
96124
this.parent.template.mutations.user.cache,
97125
{
98126
token: await this.parent.session.upToDateToken(),
99-
platformData,
127+
personName,
128+
cache,
100129
}
101130
);
102131

@@ -106,15 +135,15 @@ class SnekGqlUserTasks {
106135
/**
107136
* Get profile.
108137
*
109-
* @param {string} slug Slug: <user_<username>>
138+
* @param {string} personName personName: <schettn>
110139
* @returns {Promise<ApolloResult<ProfileData>>} The profile page of a user
111140
*/
112-
async profile(slug: string): Promise<ApolloResult<ProfileData>> {
141+
async profile(personName: string): Promise<ApolloResult<ProfileData>> {
113142
const response = await this.parent.run<ProfileData>(
114143
"query",
115144
this.parent.template.queries.user.profile,
116145
{
117-
slug,
146+
slug: `p-${personName}`,
118147
token: await this.parent.session.upToDateToken(),
119148
}
120149
);

0 commit comments

Comments
 (0)