generated from unjs/template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3553907
commit 31935e1
Showing
5 changed files
with
304 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { createApp } from 'h3' | ||
import { ApolloServer } from '@apollo/server' | ||
import { startServerAndCreateH3Handler } from '../src' | ||
|
||
const typeDefs = `#graphql | ||
# 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] | ||
} | ||
` | ||
|
||
// Resolvers define how to fetch the types defined in your schema. | ||
// This resolver returns simply a static list of books | ||
const resolvers = { | ||
Query: { | ||
books: () => [ | ||
{ | ||
title: 'The Awakening', | ||
author: 'Kate Chopin', | ||
}, | ||
{ | ||
title: 'City of Glass', | ||
author: 'Paul Auster', | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
const apollo = new ApolloServer({ | ||
typeDefs, | ||
resolvers, | ||
}) | ||
|
||
export const app = createApp() | ||
app.use('.', startServerAndCreateH3Handler(apollo, {})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.