@quell/server
Version:
Quell is an open-source NPM package providing a light-weight caching layer implementation and cache invalidation for GraphQL responses on both the client- and server-side. Use Quell to prevent redundant client-side API requests and to minimize costly serv
2 lines • 3.09 kB
TypeScript
export declare const schemaTemplate = "import { buildSchema } from 'graphql';\n\n// Example schema - replace with your own\nexport const schema = buildSchema(`\n type Book {\n id: ID!\n title: String!\n author: String!\n year: Int\n genre: String\n }\n\n type Author {\n id: ID!\n name: String!\n books: [Book]\n bio: String\n }\n\n type Query {\n books: [Book]\n book(id: ID!): Book\n authors: [Author]\n author(id: ID!): Author\n }\n\n type Mutation {\n addBook(title: String!, author: String!, year: Int, genre: String): Book\n updateBook(id: ID!, title: String, author: String, year: Int, genre: String): Book\n deleteBook(id: ID!): Boolean\n addAuthor(name: String!, bio: String): Author\n }\n`);\n\ntype Book = {\n id: string\n title: string\n author: string\n year?: number\n genre?: string\n}\n\ntype Author = {\n id: string;\n name: string;\n bio?: string;\n}\n// Sample data - replace with your database queries\nconst books: Book[] = [\n { id: '1', title: 'The Great Gatsby', author: 'F. Scott Fitzgerald', year: 1925, genre: 'Classic' },\n { id: '2', title: 'To Kill a Mockingbird', author: 'Harper Lee', year: 1960, genre: 'Classic' },\n { id: '3', title: '1984', author: 'George Orwell', year: 1949, genre: 'Dystopian' }\n];\n\nconst authors: Author[] = [\n { id: '1', name: 'F. Scott Fitzgerald', bio: 'American novelist and short story writer' },\n { id: '2', name: 'Harper Lee', bio: 'American novelist known for To Kill a Mockingbird' },\n { id: '3', name: 'George Orwell', bio: 'English novelist and essayist' }\n];\n\n// Resolvers - replace with your data fetching logic\nexport const resolvers = {\n books: () => books,\n book: ({ id }: { id: string }) => books.find(book => book.id === id),\n authors: () => authors,\n author: ({ id }: { id: string }) => authors.find(author => author.id === id),\n \n addBook: ({ title, author, year, genre }: { title: string, author: string, year?: number, genre?: string }) => {\n const newBook = {\n id: String(books.length + 1),\n title,\n author,\n year,\n genre\n };\n books.push(newBook);\n return newBook;\n },\n \n updateBook: ({ id, title, author, year, genre }: { id: string, title?: string, author?: string, year?: number, genre?: string }) => {\n const book = books.find(book => book.id === id);\n if (!book) return null;\n \n if (title) book.title = title;\n if (author) book.author = author;\n if (year !== undefined) book.year = year;\n if (genre) book.genre = genre;\n \n return book;\n },\n \n deleteBook: ({ id }: { id: string }) => {\n const index = books.findIndex(book => book.id === id);\n if (index === -1) return false;\n \n books.splice(index, 1);\n return true;\n },\n \n addAuthor: ({ name, bio }: { name: string, bio?: string }) => {\n const newAuthor = {\n id: String(authors.length + 1),\n name,\n bio\n };\n authors.push(newAuthor);\n return newAuthor;\n }\n};\n";
//# sourceMappingURL=schema.template.d.ts.map