Consolidate frontend REST calls with GraphQL
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 1s
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 1s
Replace 5 separate REST calls on home page load with a single GraphQL query. Add homeData store that fetches posts, favorites, activities, spotify, and auth in one request. Convert all admin mutations and auth flows to use GraphQL. Add album images to Spotify GraphQL schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
14
backend/graph/schema/activity.graphql
Normal file
14
backend/graph/schema/activity.graphql
Normal file
@@ -0,0 +1,14 @@
|
||||
type Activity {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
updatedAt: Time!
|
||||
type: String!
|
||||
name: String!
|
||||
link: String
|
||||
}
|
||||
|
||||
input CreateActivityInput {
|
||||
type: String!
|
||||
name: String!
|
||||
link: String
|
||||
}
|
||||
8
backend/graph/schema/auth.graphql
Normal file
8
backend/graph/schema/auth.graphql
Normal file
@@ -0,0 +1,8 @@
|
||||
input LoginInput {
|
||||
username: String!
|
||||
password: String!
|
||||
}
|
||||
|
||||
type AuthPayload {
|
||||
user: User!
|
||||
}
|
||||
14
backend/graph/schema/favorite.graphql
Normal file
14
backend/graph/schema/favorite.graphql
Normal file
@@ -0,0 +1,14 @@
|
||||
type Favorite {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
updatedAt: Time!
|
||||
type: String!
|
||||
name: String!
|
||||
link: String
|
||||
}
|
||||
|
||||
input CreateFavoriteInput {
|
||||
type: String!
|
||||
name: String!
|
||||
link: String
|
||||
}
|
||||
7
backend/graph/schema/message.graphql
Normal file
7
backend/graph/schema/message.graphql
Normal file
@@ -0,0 +1,7 @@
|
||||
type Message {
|
||||
id: ID!
|
||||
content: String!
|
||||
authorId: Int!
|
||||
fileUrl: String
|
||||
createdAt: Time!
|
||||
}
|
||||
18
backend/graph/schema/post.graphql
Normal file
18
backend/graph/schema/post.graphql
Normal file
@@ -0,0 +1,18 @@
|
||||
type Post {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
updatedAt: Time!
|
||||
title: String!
|
||||
author: User
|
||||
content: String!
|
||||
}
|
||||
|
||||
input CreatePostInput {
|
||||
title: String!
|
||||
content: String!
|
||||
}
|
||||
|
||||
input UpdatePostInput {
|
||||
title: String!
|
||||
content: String!
|
||||
}
|
||||
9
backend/graph/schema/rowing.graphql
Normal file
9
backend/graph/schema/rowing.graphql
Normal file
@@ -0,0 +1,9 @@
|
||||
type Rowing {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
date: Time!
|
||||
time: Int!
|
||||
distance: Int!
|
||||
timePer500m: Float!
|
||||
calories: Float!
|
||||
}
|
||||
29
backend/graph/schema/schema.graphql
Normal file
29
backend/graph/schema/schema.graphql
Normal file
@@ -0,0 +1,29 @@
|
||||
scalar Time
|
||||
|
||||
type Query {
|
||||
users: [User!]!
|
||||
user(id: ID!): User
|
||||
posts: [Post!]!
|
||||
post(id: ID!): Post
|
||||
activities: [Activity!]!
|
||||
favorites: [Favorite!]!
|
||||
rowingSessions: [Rowing!]!
|
||||
messages: [Message!]!
|
||||
spotifyListening: SpotifyPlaying
|
||||
spotifyRecent: [SpotifyRecentItem!]!
|
||||
me: User
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
login(input: LoginInput!): AuthPayload!
|
||||
logout: Boolean!
|
||||
refreshToken: AuthPayload!
|
||||
createPost(input: CreatePostInput!): Post!
|
||||
updatePost(id: ID!, input: UpdatePostInput!): Post!
|
||||
deletePost(id: ID!): Post!
|
||||
createUser(input: CreateUserInput!): User!
|
||||
deleteUser(id: ID!): User!
|
||||
setUserAdmin(id: ID!, admin: Boolean!): User!
|
||||
createFavorite(input: CreateFavoriteInput!): Favorite!
|
||||
createActivity(input: CreateActivityInput!): Activity!
|
||||
}
|
||||
28
backend/graph/schema/spotify.graphql
Normal file
28
backend/graph/schema/spotify.graphql
Normal file
@@ -0,0 +1,28 @@
|
||||
type SpotifyArtist {
|
||||
name: String!
|
||||
}
|
||||
|
||||
type SpotifyImage {
|
||||
url: String!
|
||||
}
|
||||
|
||||
type SpotifyAlbum {
|
||||
name: String!
|
||||
images: [SpotifyImage!]!
|
||||
}
|
||||
|
||||
type SpotifyTrack {
|
||||
name: String!
|
||||
artists: [SpotifyArtist!]!
|
||||
album: SpotifyAlbum!
|
||||
}
|
||||
|
||||
type SpotifyPlaying {
|
||||
playing: Boolean!
|
||||
track: SpotifyTrack
|
||||
}
|
||||
|
||||
type SpotifyRecentItem {
|
||||
track: SpotifyTrack!
|
||||
playedAt: Time!
|
||||
}
|
||||
12
backend/graph/schema/user.graphql
Normal file
12
backend/graph/schema/user.graphql
Normal file
@@ -0,0 +1,12 @@
|
||||
type User {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
updatedAt: Time!
|
||||
username: String!
|
||||
admin: Boolean!
|
||||
}
|
||||
|
||||
input CreateUserInput {
|
||||
username: String!
|
||||
password: String!
|
||||
}
|
||||
Reference in New Issue
Block a user