import { createSchema, createYoga } from "npm:graphql-yoga";
const typeDefs = `
type Query {
hello: String
now: String
}
`;
const resolvers = {
Query: {
hello: () => "Hello, Val Town!",
now: () => new Date().toISOString(),
},
};
const defaultQuery = `#
# Welcome to Yoga GraphiQL running on Val town
#
# Yoga GraphiQL is an in-browser tool for writing, validating, and
# testing GraphQL queries.
#
# Try a GraphQL query:
#
query MyValQuery {
hello
now
}
`;
const schema = createSchema({
typeDefs,
resolvers,
});
const yoga = createYoga({
schema,
graphqlEndpoint: "/",
graphiql: {
title: "GraphQL Yoga Val",
defaultQuery,
},
});
export default yoga.fetch;