-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Installing and using graphql-tools@7.0.2 to separate files by typeDef…
…s, queries, mutations and merge them to schema.js
- Loading branch information
Showing
12 changed files
with
4,776 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
const client = new PrismaClient(); | ||
|
||
export default client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import client from "../client.js"; | ||
|
||
export default { | ||
Mutation: { | ||
createMovie: (_, { title, year, genre }) => | ||
client.movie.create({ data: { title, year, genre } }), | ||
deleteMovie: (_, { id }) => client.movie.delete({ where: { id } }), | ||
updateMovie: (_, { id, title, year, genre }) => | ||
client.movie.update({ where: { id }, data: { title, year, genre } }), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import client from "../client.js"; | ||
|
||
export default { | ||
Query: { | ||
movies: () => client.movie.findMany(), | ||
movie: (_, { id }) => client.movie.findUnique({ where: { id } }), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { gql } from "apollo-server"; | ||
|
||
export default gql` | ||
type Movie { | ||
id: Int! | ||
title: String! | ||
year: Int! | ||
genre: String | ||
createdAt: String | ||
updatedAt: String | ||
} | ||
type Query { | ||
movies: [Movie] | ||
movie(id: Int!): Movie | ||
} | ||
type Mutation { | ||
createMovie(title: String!, year: Int!, genre: String): Movie | ||
deleteMovie(id: Int!): Movie | ||
updateMovie(id: Int!, title: String, year: Int, genre: String): Movie | ||
} | ||
`; |
Oops, something went wrong.