-
Notifications
You must be signed in to change notification settings - Fork 16
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
3fdff10
commit d44093c
Showing
9 changed files
with
193 additions
and
79 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,45 @@ | ||
import { g, Infer, InferResolvers, buildSchema } from './../src/index' | ||
import { createYoga } from 'graphql-yoga' | ||
import { createServer } from 'http' | ||
|
||
const node = { | ||
id: g.id() | ||
} | ||
|
||
const name = { | ||
name: g.string() | ||
} | ||
|
||
const test = g.type('Test', {}).extend([node, name]) | ||
|
||
const queryType = g.type('Query', { | ||
test: g.ref(() => test) | ||
}) | ||
|
||
type Test = Infer<typeof test> | ||
|
||
const resolvers: InferResolvers<{ Query: typeof queryType, Test: typeof test }, {}> = { | ||
Query: { | ||
test: (parent, args, context, info) => { | ||
return { | ||
id: '123', | ||
name: 'Test' | ||
} | ||
} | ||
}, | ||
Test: { | ||
id: (parent, args, context, info) => { | ||
return parent.id | ||
}, | ||
name: (parent, args, context, info) => { | ||
return parent.name | ||
} | ||
} | ||
} | ||
|
||
const schema = buildSchema({ g, resolvers }) | ||
const yoga = createYoga({ schema }) | ||
const server = createServer(yoga) | ||
server.listen(4000, () => { | ||
console.info('Server is running on http://localhost:4000/graphql') | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.