-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit ffa6704
Showing
7 changed files
with
723 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,28 @@ | ||
import Koa from "koa" | ||
import { readFileSync } from "fs" | ||
import { join, dirname } from "path" | ||
import { fileURLToPath } from 'url' | ||
import bodyParser from "koa-bodyparser" | ||
import tools from 'graphql-tools' | ||
const { makeExecutableSchema } = tools | ||
|
||
import graphql from "../src/koa" | ||
|
||
const dir = dirname(fileURLToPath(import.meta.url)) | ||
|
||
const app = new Koa() | ||
.use(bodyParser()) | ||
.use(graphql({ | ||
schema: makeExecutableSchema({ | ||
typeDefs: readFileSync(join(dir, "schema.gql"), "utf-8"), | ||
resolvers: { | ||
Query: { | ||
hello(root, { name }) { | ||
return `Hello ${name} !` | ||
} | ||
} | ||
} | ||
}) | ||
})) | ||
|
||
const server = app.listen(3000, () => console.log("Listening on ", server.address())) |
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,16 @@ | ||
type Query { | ||
hello(name: String!): String! | ||
me: User | ||
} | ||
|
||
type User { | ||
sayHello(to: String!): String! | ||
} | ||
|
||
type Mutation { | ||
sendMessage(message: String!): String! | ||
} | ||
|
||
type Subscription { | ||
onMessage: String | ||
} |
Oops, something went wrong.