1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { createSchema, createYoga } from "npm:graphql-yoga";
const typeDefs = /* GraphQL */ `
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
}
`;
// Create a Yoga GraphQL schema
const schema = createSchema({
typeDefs,
resolvers,
});
// Create a Yoga GraphQL server
const yoga = createYoga({
schema,
graphqlEndpoint: "/",
graphiql: {
title: "GraphQL Yoga Val",
defaultQuery,
},
});
export default yoga.fetch;