Initial commit

This commit is contained in:
Bohdan Denysenko 2024-12-29 10:56:43 +00:00 • committed by GitHub
commit 864f37a652
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 45596 additions and 0 deletions

View file

@ -0,0 +1,15 @@
/* gql imports */
import { QueryResolvers } from "@generated/graphql";
/* Query */
import { BooksManyResolver } from "./resolvers/booksManyResolver";
import { BookOneResolver } from "./resolvers/bookOneResolver";
export const Query: QueryResolvers = {
booksMany: BooksManyResolver,
bookOne: BookOneResolver,
};
export const Mutation = {};
export const Subscription = {};

View file

@ -0,0 +1,13 @@
import { BookInput, Book } from "@generated/graphql";
import { books } from "./booksManyResolver";
export async function BookOneResolver(
_: any,
{ ...input }: BookInput,
): Promise<Book> {
console.log("Called 'BookOneResolver' resolver...");
const book = books.filter((item) => item.id === input.id)[0];
return book;
}

View file

@ -0,0 +1,20 @@
import { Book } from "@generated/graphql";
export const books = [
{
id: "1",
title: "some-title-1",
author: "someone",
},
{
id: "2",
title: "some-title-1",
author: "someone",
},
];
export async function BooksManyResolver(_: any): Promise<Book[]> {
console.log("Called 'BooksManyResolver' resolver...");
return books;
}

View file

@ -0,0 +1,14 @@
type Query {
booksMany: [Book]!
bookOne(input: BookInput!): [Book]!
}
type Book {
id: ID!
title: String!
author: String!
}
input BookInput {
id: ID!
}