Static type checking between resolvers and typedef

// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
import gql from 'graphql-tag'
export const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

# This "Book" type defines the queryable fields for every book in our data source.
type Book {
title: String
author: String
}

# The "Query" type is special: it lists all of the available queries that
# clients can execute, along with the return type for each. In this
# case, the "books" query returns an array of zero or more Books (defined above).
type Query {
books: [Book]
}
`;
// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
import gql from 'graphql-tag'
export const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

# This "Book" type defines the queryable fields for every book in our data source.
type Book {
title: String
author: String
}

# The "Query" type is special: it lists all of the available queries that
# clients can execute, along with the return type for each. In this
# case, the "books" query returns an array of zero or more Books (defined above).
type Query {
books: [Book]
}
`;
Resolver
import { books } from "./types/books";
import { prisma } from "../db/client";

export const resolvers = {
Query: {
books: async () => {
return await prisma.book.findMany();
},
},
};
import { books } from "./types/books";
import { prisma } from "../db/client";

export const resolvers = {
Query: {
books: async () => {
return await prisma.book.findMany();
},
},
};
1 Reply
JacobMGEvans
JacobMGEvans2y ago
What's the question? You can recreate the question with more clarification.
Want results from more Discord servers?
Add your server