Skip to content

Commit

Permalink
Update profile query and task
Browse files Browse the repository at this point in the history
Once again, the profile query and task have been
updated due to a structure change in engine.
  • Loading branch information
schettn committed Aug 24, 2020
1 parent c73ba3a commit 37b77da
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
47 changes: 35 additions & 12 deletions src/templates/snek/gql/queries/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,49 @@ const whoami = gql`
/**
* Get user profile.
*
* @param {string} slug Slug: <user_<username>>
* @param {string} slug Slug: <p-<personName>>
* @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
}
}
`;
Expand Down
34 changes: 29 additions & 5 deletions src/templates/snek/gql/tasks/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}

Expand Down Expand Up @@ -106,15 +130,15 @@ class SnekGqlUserTasks {
/**
* Get profile.
*
* @param {string} username Username: <username>
* @param {string} slug Slug: <p-<personName>>
* @returns {Promise<ApolloResult<ProfileData>>} The profile page of a user
*/
async profile(username: string): Promise<ApolloResult<ProfileData>> {
async profile(slug: string): Promise<ApolloResult<ProfileData>> {
const response = await this.parent.run<ProfileData>(
"query",
this.parent.template.queries.user.profile,
{
username,
slug,
token: await this.parent.session.upToDateToken(),
}
);
Expand Down

0 comments on commit 37b77da

Please sign in to comment.