PlanetScale 2. On a server side, use Firebase Auth and Cloud Storage with Firebase Admin 3. Update the logic of uploading and watching a video with a server side code
Upload a video Upload a video Upload the video Upload the video Submit Submit Send its metadata Send its metadata Fetch its metadata Fetch its metadata Metadata Metadata Update its metadata Update its metadata Store its metadata Store its metadata Respond with its video id Respond with its video id Show the video detail page Show the video detail page User Browser GraphQL Cloud Storage MySQL
Go to a video page Go to a video page Get video data Get video data Get video metadata by its id Get video metadata by its id Video metadata Video metadata Fetch the metadata of the video Fetch the metadata of the video Metadata Metadata Video metadata Video metadata Fetch a video file Fetch a video file Video Video Show a video detail page Show a video detail page User Browser GraphQL Cloud Storage MySQL
a Next.js official repository to set up GraphQL and Prisma GraphQL GraphQL Yoda TypeGraphQL MySQL integration by Prisma and PlanetScale Prisma PlanetScale
a server in the /pages/api/{url} import { createServer } from "@graphql-yoga/node"; const server = createServer({ schema: { typeDefs, resolvers, }, endpoint: "/api/graphql", }); export default server;
and resolvers with TypeScript. The code like next for data types. @ObjectType() class Video { @Field((type) => ID) id: number; // ... } @InputType() class VideoInput { @Field() title: string; // ... }
example of setting up Prisma with PlanetScale in Next.js repository MySQL integration by Prisma and PlanetScale Prisma PlanetScale Followed a few steps for the tutorial of PlanetScale to migrate a database.
few things I needed to be careful to use Prisma With PlanetScale, the step to apply migration is different Just push a database and pull it to the branch When I tried to use prisma migrate dev --name init , there is an error which shadow DB cannot be created. Error: P3014 Prisma Migrate could not create the shadow database. // Original error: create database is not supported 0: migration_core::state::DevDiagnostic at migration-engine/core/src/state.rs:250
are created with the definitions of Prisma models without any conversions In some cases, DB tables schemas are defined with plural and snake cases To change naming conventions of table schemas with models, use @@map and @map attribute descried here It seems there is no way to convert them automaticallly without defining the attributes
a frontend to a Cloud Storage directly without the server 2. Send the metadata of the video to the server side and update it 1. It's required to verify whether it's the same between the file a user uploads originally and a filepath set by a user later 1. Use md5hash of the metadata of a GCS object 3. Store filename, user id and other metadata in MySQL