mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Set up GQL client
This commit is contained in:
parent
ec77cb1d24
commit
6833439a4a
14 changed files with 1349 additions and 418 deletions
19
src/graphql/apolloClient.mts
Normal file
19
src/graphql/apolloClient.mts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { makeExecutableSchema } from "@graphql-tools/schema";
|
||||
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
||||
import { SchemaLink } from "@apollo/client/link/schema"
|
||||
|
||||
import { typeDefs } from "./__generated__/typeDefs.generated";
|
||||
import { resolvers } from "./__generated__/resolvers.generated";
|
||||
|
||||
const schema = makeExecutableSchema({ typeDefs, resolvers })
|
||||
export type ResolverContext = { request?: Request; /*session?: Session */ }
|
||||
|
||||
export async function getApolloClient(request?: Request) {
|
||||
// const session = request ? await getSession(request) : undefined
|
||||
|
||||
return new ApolloClient({
|
||||
ssrMode: true,
|
||||
link: new SchemaLink({ schema, context: { request } }),
|
||||
cache: new InMemoryCache()
|
||||
})
|
||||
}
|
||||
301
src/graphql/typeDefs/album.graphql
Normal file
301
src/graphql/typeDefs/album.graphql
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
type Album {
|
||||
id: ID!
|
||||
title: String!
|
||||
subTitle: String
|
||||
releaseDate: String!
|
||||
label: String
|
||||
vgmdb: String
|
||||
description: String
|
||||
stores: [Store]!
|
||||
discs: [Disc]!
|
||||
artists: [Artist]!
|
||||
categories: [Category]!
|
||||
classifications: [Classification]!
|
||||
platforms: [Platform]!
|
||||
games: [Game]!
|
||||
animations: [Animation]!
|
||||
downloads: [Download]!
|
||||
related: [Album]!
|
||||
updatedAt: Float!
|
||||
createdAt: Float!
|
||||
status: String!
|
||||
placeholder: String
|
||||
headerColor: String!
|
||||
}
|
||||
|
||||
type Disc {
|
||||
id: ID!
|
||||
number: Int
|
||||
body: String
|
||||
tracks: [String]
|
||||
album: Album
|
||||
}
|
||||
|
||||
type Download {
|
||||
id: ID!
|
||||
title: String
|
||||
small: Boolean
|
||||
links: [Link]
|
||||
}
|
||||
|
||||
type Store {
|
||||
id: ID!
|
||||
provider: String
|
||||
url: String
|
||||
}
|
||||
|
||||
type Link {
|
||||
id: ID!
|
||||
provider: String
|
||||
custom: String
|
||||
url: String
|
||||
directUrl: String
|
||||
}
|
||||
|
||||
type Artist {
|
||||
name: String!
|
||||
slug: String!
|
||||
albums: [Album]
|
||||
}
|
||||
|
||||
type Category {
|
||||
name: String!
|
||||
albums: [Album]!
|
||||
count: Int!
|
||||
}
|
||||
|
||||
type Classification {
|
||||
name: String!
|
||||
}
|
||||
|
||||
type Game {
|
||||
slug: String!
|
||||
name: String
|
||||
releaseDate: String
|
||||
placeholder: String
|
||||
publishers: [Publisher]
|
||||
platforms: [Platform]
|
||||
albums(order: [String]): [Album]
|
||||
series: [Series]
|
||||
headerColor: String!
|
||||
}
|
||||
|
||||
type Animation {
|
||||
id: ID!
|
||||
title: String
|
||||
subTitle: String
|
||||
releaseDate: String
|
||||
placeholder: String
|
||||
studios: [Studio]!
|
||||
albums(order: [String]): [Album]!
|
||||
headerColor: String!
|
||||
}
|
||||
|
||||
type Studio {
|
||||
slug: String!
|
||||
name: String
|
||||
animations: [Animation]!
|
||||
}
|
||||
|
||||
type Platform {
|
||||
id: ID!
|
||||
name: String
|
||||
type: String!
|
||||
albums: [Album]
|
||||
games: [Game]!
|
||||
}
|
||||
|
||||
type Publisher {
|
||||
id: ID!
|
||||
name: String
|
||||
games: [Game]
|
||||
}
|
||||
|
||||
type Series {
|
||||
slug: String!
|
||||
name: String
|
||||
placeholder: String
|
||||
games: [Game]
|
||||
headerColor: String!
|
||||
}
|
||||
|
||||
type Query {
|
||||
albums: [Album!]!
|
||||
downloads(id: ID!): [Download]!
|
||||
albumCount: Float!
|
||||
categories: [Category]!
|
||||
classifications: [Classification]!
|
||||
album(id: ID): Album
|
||||
artists: [Artist!]!
|
||||
platforms: [Platform!]!
|
||||
platform(id: ID): Platform!
|
||||
publishers: [Publisher]!
|
||||
publisher(id: ID!): Publisher!
|
||||
series: [Series]!
|
||||
seriesOne(slug: String): Series
|
||||
games: [Game!]!
|
||||
game(slug: String): Game!
|
||||
animations: [Animation]!
|
||||
animation(id: ID): Animation!
|
||||
studios: [Studio]!
|
||||
studio(slug: String!): Studio!
|
||||
|
||||
highlight: Album!
|
||||
|
||||
searchAlbum(
|
||||
title: String
|
||||
categories: [String]
|
||||
limit: Int
|
||||
page: Int
|
||||
order: [String]
|
||||
mode: String
|
||||
status: [String!]
|
||||
): SearchAlbumResult
|
||||
searchAlbumByArtist(
|
||||
name: String!
|
||||
categories: [String]
|
||||
limit: Int
|
||||
page: Int
|
||||
order: [String]
|
||||
mode: String
|
||||
status: [String!]
|
||||
): SearchAlbumResult
|
||||
searchAnimation(
|
||||
title: String
|
||||
limit: Int
|
||||
page: Int
|
||||
order: String
|
||||
mode: String
|
||||
): SearchAnimResult
|
||||
searchStudio(
|
||||
name: String
|
||||
limit: Int
|
||||
page: Int
|
||||
order: String
|
||||
mode: String
|
||||
): SearchStudioResult
|
||||
searchGame(
|
||||
name: String
|
||||
limit: Int
|
||||
page: Int
|
||||
order: String
|
||||
mode: String
|
||||
): SearchGameResult
|
||||
searchSeries(
|
||||
name: String
|
||||
limit: Int
|
||||
page: Int
|
||||
order: String
|
||||
mode: String
|
||||
): SearchSeriesResult
|
||||
|
||||
searchSeriesByName(name: String): [Series]
|
||||
recentSeries(limit: Int!): [Series]
|
||||
searchPublishersByName(name: String): [Publisher]
|
||||
recentPublishers(limit: Int!): [Publisher]
|
||||
searchPlatformsByName(name: String, categories: [String]!): [Platform]
|
||||
searchPlatformsByCategories(categories: [String]!): [Platform]!
|
||||
recentPlatforms(limit: Int!, type: [String]!): [Platform]
|
||||
|
||||
getRandomAlbum(limit: Int): [Album!]!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createPlatform(name: String, type: String!): Platform!
|
||||
updatePlatform(key: ID!, name: String, type: String!): Platform!
|
||||
deletePlatform(key: ID!): Int
|
||||
|
||||
createPublisher(name: String): Publisher!
|
||||
updatePublisher(id: ID!, name: String): Publisher!
|
||||
deletePublisher(id: ID!): Int
|
||||
|
||||
createSeries(slug: String, name: String, cover: Upload!): Series!
|
||||
updateSeries(slug: String, name: String, cover: Upload): Series!
|
||||
deleteSeries(slug: String!): Int
|
||||
|
||||
createGame(
|
||||
releaseDate: String
|
||||
slug: String
|
||||
name: String
|
||||
publishers: [ID]
|
||||
series: [String]
|
||||
platforms: [ID]
|
||||
cover: Upload!
|
||||
): Game!
|
||||
updateGame(
|
||||
releaseDate: String
|
||||
slug: String
|
||||
name: String
|
||||
publishers: [ID]
|
||||
series: [String]
|
||||
platforms: [ID]
|
||||
cover: Upload
|
||||
): Game!
|
||||
deleteGame(slug: String!): Int
|
||||
|
||||
createStudio(slug: String, name: String): Studio!
|
||||
updateStudio(slug: String, name: String): Studio!
|
||||
deleteStudio(slug: String!): Int
|
||||
|
||||
createAnimation(
|
||||
title: String
|
||||
subTitle: String
|
||||
releaseDate: String
|
||||
studios: [String]
|
||||
cover: Upload
|
||||
): Animation
|
||||
updateAnimation(
|
||||
id: ID!
|
||||
title: String
|
||||
subTitle: String
|
||||
releaseDate: String
|
||||
studios: [String]
|
||||
cover: Upload
|
||||
): Animation
|
||||
deleteAnimation(id: ID!): Int
|
||||
|
||||
createAlbum(
|
||||
title: String
|
||||
subTitle: String
|
||||
cover: Upload
|
||||
releaseDate: String
|
||||
label: String
|
||||
vgmdb: String
|
||||
description: String
|
||||
stores: [StoreInput]
|
||||
downloads: [DownloadInput]
|
||||
artists: [String]
|
||||
categories: [String]
|
||||
classifications: [String]
|
||||
platforms: [ID]
|
||||
games: [String]
|
||||
animations: [ID]
|
||||
discs: [DiscInput]
|
||||
related: [ID]
|
||||
status: String!
|
||||
request: ID
|
||||
): Album!
|
||||
updateAlbum(
|
||||
id: ID!
|
||||
title: String
|
||||
subTitle: String
|
||||
cover: Upload
|
||||
releaseDate: String
|
||||
label: String
|
||||
vgmdb: String
|
||||
description: String
|
||||
stores: [StoreInput]
|
||||
downloads: [DownloadInput]
|
||||
artists: [String]
|
||||
categories: [String]
|
||||
classifications: [String]
|
||||
platforms: [ID]
|
||||
games: [String]
|
||||
animations: [ID]
|
||||
discs: [DiscInput]
|
||||
related: [ID]
|
||||
status: String!
|
||||
request: ID
|
||||
): Album!
|
||||
deleteAlbum(id: ID!): Int
|
||||
}
|
||||
42
src/graphql/typeDefs/comment&favorite.graphql
Normal file
42
src/graphql/typeDefs/comment&favorite.graphql
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
type Comment {
|
||||
id: ID!
|
||||
text: String!
|
||||
anon: Boolean!
|
||||
album: Album!
|
||||
username: String
|
||||
}
|
||||
|
||||
type Album {
|
||||
comments: [Comment]!
|
||||
selfComment: Comment
|
||||
isFavorite: Boolean
|
||||
favorites: Int!
|
||||
avgRating: AvgRating!
|
||||
selfScore: Int
|
||||
}
|
||||
|
||||
type User {
|
||||
comments: [Comment]!
|
||||
favorites: [Album]!
|
||||
}
|
||||
|
||||
type UserMe {
|
||||
comments: [Comment]!
|
||||
favorites: [Album]!
|
||||
}
|
||||
|
||||
type AvgRating {
|
||||
score: Float!
|
||||
users: Int!
|
||||
}
|
||||
|
||||
type Query {
|
||||
recentComments(limit: Int): [Comment]!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
updateComment(text: String!, anon: Boolean!, albumId: ID!): Boolean
|
||||
addFavorite(albumId: String!): Boolean
|
||||
removeFavorite(albumId: String!): Boolean
|
||||
rateAlbum(albumId: ID!, score: Int!): Boolean
|
||||
}
|
||||
27
src/graphql/typeDefs/queryInputs.graphql
Normal file
27
src/graphql/typeDefs/queryInputs.graphql
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
input ArtistInput {
|
||||
name: String!
|
||||
slug: String!
|
||||
}
|
||||
|
||||
input StoreInput {
|
||||
provider: String!
|
||||
url: String!
|
||||
}
|
||||
|
||||
input DownloadInput {
|
||||
title: String
|
||||
small: Boolean
|
||||
links: [LinkInput]
|
||||
}
|
||||
|
||||
input LinkInput {
|
||||
provider: String
|
||||
custom: String
|
||||
url: String
|
||||
directUrl: String
|
||||
}
|
||||
|
||||
input DiscInput {
|
||||
number: Int
|
||||
body: String
|
||||
}
|
||||
64
src/graphql/typeDefs/requests.graphql
Normal file
64
src/graphql/typeDefs/requests.graphql
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
type Request {
|
||||
id: ID!
|
||||
title: String
|
||||
link: String
|
||||
user: String
|
||||
userID: String
|
||||
state: String!
|
||||
donator: Boolean!
|
||||
reason: String
|
||||
comments: String
|
||||
message: String
|
||||
}
|
||||
|
||||
type Submission {
|
||||
id: ID!
|
||||
title: String!
|
||||
vgmdb: String
|
||||
request: Request
|
||||
links: String
|
||||
score: Int!
|
||||
state: String!
|
||||
submitter: User!
|
||||
}
|
||||
|
||||
type RequestResult {
|
||||
count: Int!
|
||||
rows: [Request]!
|
||||
}
|
||||
|
||||
type Query {
|
||||
requests(
|
||||
state: [String!],
|
||||
donator: [Boolean]!
|
||||
): [Request]!
|
||||
request(link: String!): Request
|
||||
searchRequests(
|
||||
state: [String!]
|
||||
donator: [Boolean!]
|
||||
limit: Int
|
||||
page: Int
|
||||
filter: String
|
||||
): RequestResult!
|
||||
submissions(filter: String, state: [String]): [Submission]!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
editRequest(
|
||||
id: ID!
|
||||
title: String
|
||||
link: String
|
||||
state: String
|
||||
comments: String
|
||||
reason: String
|
||||
): Request!
|
||||
|
||||
submitAlbum(
|
||||
title: String!
|
||||
vgmdb: String
|
||||
request: ID
|
||||
links: String!
|
||||
): Submission!
|
||||
|
||||
rejectRequest(id: ID!, reason: String): Boolean!
|
||||
}
|
||||
24
src/graphql/typeDefs/searchResults.graphql
Normal file
24
src/graphql/typeDefs/searchResults.graphql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type SearchAlbumResult {
|
||||
rows: [Album]
|
||||
count: Int
|
||||
}
|
||||
|
||||
type SearchAnimResult {
|
||||
rows: [Animation]
|
||||
count: Int
|
||||
}
|
||||
|
||||
type SearchStudioResult {
|
||||
rows: [Studio]
|
||||
count: Int
|
||||
}
|
||||
|
||||
type SearchGameResult {
|
||||
rows: [Game]
|
||||
count: Int
|
||||
}
|
||||
|
||||
type SearchSeriesResult {
|
||||
rows: [Series]
|
||||
count: Int
|
||||
}
|
||||
22
src/graphql/typeDefs/site.graphql
Normal file
22
src/graphql/typeDefs/site.graphql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
scalar Upload
|
||||
scalar JSON
|
||||
scalar JSONObject
|
||||
|
||||
type Config {
|
||||
name: String!
|
||||
value: String!
|
||||
}
|
||||
|
||||
type Query {
|
||||
config(name: String): Config
|
||||
banners: [String]!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
uploadBanner(banner: Upload!): Int
|
||||
selectBanner(name: String!): Int
|
||||
config(
|
||||
name: String!
|
||||
value: String!
|
||||
): Config!
|
||||
}
|
||||
57
src/graphql/typeDefs/user.graphql
Normal file
57
src/graphql/typeDefs/user.graphql
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
type User {
|
||||
username: String!
|
||||
roles: [Role]!
|
||||
permissions: [String]!
|
||||
pages: [Page]!
|
||||
createdAt: Float!
|
||||
placeholder: String!
|
||||
imgUrl: String!
|
||||
}
|
||||
|
||||
type UserMe {
|
||||
email: String!
|
||||
username: String!
|
||||
roles: [Role]!
|
||||
permissions: [String]!
|
||||
pages: [Page]!
|
||||
createdAt: Float!
|
||||
placeholder: String!
|
||||
imgUrl: String!
|
||||
}
|
||||
|
||||
type Page {
|
||||
url: String!
|
||||
perms: [String!]!
|
||||
}
|
||||
|
||||
type Role {
|
||||
name: String!
|
||||
permissions: [String]!
|
||||
}
|
||||
|
||||
type Query {
|
||||
me: UserMe
|
||||
roles: [Role]!
|
||||
permissions: [String]!
|
||||
users(search: String): [User]!
|
||||
user(username: String!): User
|
||||
|
||||
login(username: String!, password: String!): Int!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
login(username: String!, password: String!): Int!
|
||||
logout: Int!
|
||||
|
||||
registerUser(email: String!, username: String!, pfp: Upload): Boolean!
|
||||
updateUserRoles(username: String!, roles: [String]!): Boolean!
|
||||
deleteUser(username: String!): Int
|
||||
|
||||
createForgorLink(key: String!): Boolean!
|
||||
updatePass(key: String!, pass:String!): Boolean!
|
||||
updateUser(username: String, password: String, email: String, pfp: Upload): Boolean!
|
||||
|
||||
createRole(name: String!, permissions: [String]!): Role
|
||||
updateRole(key:String!, name: String!, permissions: [String]!): Role
|
||||
deleteRole(name: String!): String
|
||||
}
|
||||
19
src/graphql/typeDefs/vgmdb.graphql
Normal file
19
src/graphql/typeDefs/vgmdb.graphql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
type VgmResult {
|
||||
title: String
|
||||
subTitle: String
|
||||
releaseDate: String
|
||||
coverUrl: String
|
||||
artists: [String]!
|
||||
categories: [String]!
|
||||
classifications: [String]!
|
||||
trackList: [VGMDBDisc]!
|
||||
}
|
||||
|
||||
type VGMDBDisc {
|
||||
number: Int
|
||||
tracks: [String!]
|
||||
}
|
||||
|
||||
type Query {
|
||||
vgmdb(url: String!): VgmResult
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue