Skip to content

Commit 37b77da

Browse files
committed
Update profile query and task
Once again, the profile query and task have been updated due to a structure change in engine.
1 parent c73ba3a commit 37b77da

File tree

2 files changed

+64
-17
lines changed

2 files changed

+64
-17
lines changed

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

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,49 @@ 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`
33-
query profile($username: String!, $token: String!) {
34-
profile: user(username: $username, token: $token) {
35-
username
36-
firstName
37-
lastName
38-
email
39-
verified: isActive
40-
personpage {
41-
title
33+
query profile($slug: String!, $token: String!) {
34+
page(slug: $slug, token: $token) {
35+
... on PersonFormPage {
36+
personName: title
37+
firstName
38+
lastName
39+
email
40+
platformData: cache
41+
sources
42+
person {
43+
cache
44+
sources
45+
}
4246
tids
4347
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+
}
4469
}
45-
platformData: cache
46-
sources
4770
}
4871
}
4972
`;

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

Lines changed: 29 additions & 5 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

@@ -106,15 +130,15 @@ class SnekGqlUserTasks {
106130
/**
107131
* Get profile.
108132
*
109-
* @param {string} username Username: <username>
133+
* @param {string} slug Slug: <p-<personName>>
110134
* @returns {Promise<ApolloResult<ProfileData>>} The profile page of a user
111135
*/
112-
async profile(username: string): Promise<ApolloResult<ProfileData>> {
136+
async profile(slug: string): Promise<ApolloResult<ProfileData>> {
113137
const response = await this.parent.run<ProfileData>(
114138
"query",
115139
this.parent.template.queries.user.profile,
116140
{
117-
username,
141+
slug,
118142
token: await this.parent.session.upToDateToken(),
119143
}
120144
);

0 commit comments

Comments
 (0)