Skip to content

Commit

Permalink
feat: add api query creator profile
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Aug 5, 2024
1 parent 23329f7 commit 04bc6a1
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 11 deletions.
27 changes: 27 additions & 0 deletions hasura/metadata/databases/punkga-pg/tables/public_artworks.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
table:
name: artworks
schema: public
select_permissions:
- role: anonymous
permission:
columns:
- contest_id
- contest_round
- creator_id
- id
- source_url
- url
- created_at
- updated_at
filter: {}
allow_aggregations: true
- role: user
permission:
columns:
- contest_id
- contest_round
- creator_id
- id
- source_url
- url
- created_at
- updated_at
filter: {}
allow_aggregations: true
38 changes: 38 additions & 0 deletions hasura/metadata/databases/punkga-pg/tables/public_contest.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
table:
name: contest
schema: public
array_relationships:
- name: contest_artworks
using:
foreign_key_constraint_on:
column: contest_id
table:
name: artworks
schema: public
- name: contest_mangas
using:
foreign_key_constraint_on:
column: contest_id
table:
name: manga
schema: public
select_permissions:
- role: anonymous
permission:
columns:
- id
- slug
- created_at
- end_date
- start_date
- updated_at
filter: {}
allow_aggregations: true
- role: user
permission:
columns:
- id
- slug
- created_at
- end_date
- start_date
- updated_at
filter: {}
allow_aggregations: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ table:
name: creators
schema: public
array_relationships:
- name: creators_artworks
using:
foreign_key_constraint_on:
column: creator_id
table:
name: artworks
schema: public
- name: manga_creators
using:
foreign_key_constraint_on:
Expand Down
29 changes: 29 additions & 0 deletions hasura/metadata/databases/punkga-pg/tables/public_launchpad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,32 @@ array_relationships:
table:
name: i18n
schema: public
select_permissions:
- role: anonymous
permission:
columns:
- contract_address
- status
- creator_id
- id
- featured_images
- fund
- slug
- created_at
- updated_at
filter: {}
allow_aggregations: true
- role: user
permission:
columns:
- contract_address
- status
- creator_id
- id
- featured_images
- fund
- slug
- created_at
- updated_at
filter: {}
allow_aggregations: true
22 changes: 12 additions & 10 deletions hasura/metadata/databases/punkga-pg/tables/public_manga.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ select_permissions:
- role: anonymous
permission:
columns:
- banner
- contract_addresses
- created_at
- contest_id
- id
- contract_addresses
- banner
- poster
- publish_date
- release_date
- slug
- status
- created_at
- publish_date
- release_date
- updated_at
computed_fields:
- latest_published
Expand All @@ -96,15 +97,16 @@ select_permissions:
- role: user
permission:
columns:
- banner
- contract_addresses
- created_at
- contest_id
- id
- contract_addresses
- banner
- poster
- publish_date
- release_date
- slug
- status
- created_at
- publish_date
- release_date
- updated_at
computed_fields:
- latest_published
Expand Down
134 changes: 134 additions & 0 deletions hasura/metadata/query_collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,3 +1218,137 @@
}
}
}
- name: Public - Get manga by creator
query: |
query manga ($id: Int!, $limit: Int = 10, $offset: Int = 0) {
manga(limit: $limit, offset: $offset, where: {manga_creators:{creator_id:{_eq:$id}},status:{_neq:"Removed"}}) {
id
slug
status
poster
banner
manga_creators {
creator {
name
pen_name
id
slug
}
}
manga_total_likes {
likes
}
manga_total_views {
views
}
manga_tags {
tag {
tag_languages {
language_id
value
}
id
}
}
chapters(limit: 1, order_by: {chapter_number:desc}, where: {status:{_eq:"Published"}}) {
id
chapter_number
chapter_name
}
contract_addresses
manga_languages {
id
is_main_language
title
description
language_id
}
}
}
- name: Public - query artwork by creator
query: |
query artworks ($creator_id: Int!, $limit: Int = 10, $offset: Int = 0) {
artworks(where: {creator_id:{_eq:$creator_id}}, limit: $limit, offset: $offset) {
id
url
contest_id
contest_round
source_url
}
artworks_aggregate(where: {creator_id:{_eq:$creator_id}}) {
aggregate {
count
}
}
}
- name: Public - Get creator launchpad
query: |
query launchpad ($creator_id: Int!) {
launchpad(where: {creator_id:{_eq:$creator_id}}) {
id
slug
launchpad_i18ns {
data
i18n_language {
is_main
symbol
id
}
}
featured_images
contract_address
created_at
launchpad_creator {
id
slug
pen_name
avatar_url
}
}
}
- name: Public - Get manga by creator and contest
query: |
query manga ($contest_id: Int!, $id: Int!, $limit: Int = 100, $offset: Int = 0) {
manga(where: {contest_id:{_eq:$contest_id},manga_creators:{creator_id:{_eq:$id}}}, limit: $limit, offset: $offset) {
banner
id
slug
poster
}
manga_aggregate(where: {contest_id:{_eq:$contest_id},manga_creators:{creator_id:{_eq:$id}}}, limit: $limit, offset: $offset) {
aggregate {
count
}
}
}
- name: Public - Get contest by creator id
query: |
query contest ($creator_id: Int!, $limit: Int = 10, $offset: Int = 0) {
contest(where: {_or:[{contest_artworks:{creator_id:{_eq:$creator_id}}},{contest_mangas:{manga_creators:{creator_id:{_eq:$creator_id}}}}]}, limit: $limit, offset: $offset) {
id
start_date
end_date
slug
created_at
}
contest_aggregate(where: {_or:[{contest_artworks:{creator_id:{_eq:$creator_id}}},{contest_mangas:{manga_creators:{creator_id:{_eq:$creator_id}}}}]}, limit: $limit, offset: $offset) {
aggregate {
count
}
}
}
- name: Public - Get artwork by creator and contest
query: |
query artwork ($contest_id: Int!, $id: Int!, $limit: Int = 100, $offset: Int = 0) {
artworks(where: {contest_id:{_eq:$contest_id},creator_id:{_eq:$id}}, limit: $limit, offset: $offset) {
id
url
source_url
created_at
}
artworks_aggregate(where: {contest_id:{_eq:$contest_id},creator_id:{_eq:$id}}, limit: $limit, offset: $offset) {
aggregate {
count
}
}
}
54 changes: 54 additions & 0 deletions hasura/metadata/rest_endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,60 @@
- GET
name: Public - Get Chapter Comments
url: public/chapters/:chapter_id/comments
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - query artwork by creator
methods:
- GET
name: Public - query artwork by creator
url: public/creators/:creator_id/artworks
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - Get contest by creator id
methods:
- GET
name: Public - Get contest by creator id
url: public/creators/:creator_id/contests
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - Get creator launchpad
methods:
- GET
name: Public - Get creator launchpad
url: public/creators/:creator_id/launchpad
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - Get artwork by creator and contest
methods:
- GET
name: Public - Get artwork by creator and contest
url: public/creators/:id/contests/:contest_id/artworks
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - Get manga by creator and contest
methods:
- GET
name: Public - Get manga by creator and contest
url: public/creators/:id/contests/:contest_id/manga
- comment: ""
definition:
query:
collection_name: allowed-queries
query_name: Public - Get manga by creator
methods:
- GET
name: Public - Get manga by creator
url: public/creators/:id/manga
- comment: ""
definition:
query:
Expand Down
2 changes: 1 addition & 1 deletion src/modules/creator/creator.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class CreatorGraphql {
constructor(
private configSvc: ConfigService,
private graphqlSvc: GraphqlService
) { }
) {}

queryCreatorByIdOrSlug(variables: any) {
return this.graphqlSvc.query(
Expand Down

0 comments on commit 04bc6a1

Please sign in to comment.