Skip to content

Commit fdce634

Browse files
authored
Merge pull request #164 from graphql-binding/codegen
Codegen
2 parents 36077e4 + 086e14d commit fdce634

11 files changed

+7148
-122
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
.DS_Store
33
*.log
44
dist
5-
.vscode
5+
.vscode
6+
.envrc

.graphqlconfig.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
schemaPath: src/schema.graphql
2+
extensions:
3+
endpoints:
4+
default:
5+
url: https://api.github.com/graphql
6+
headers:
7+
Authorization: "Bearer ${env:GITHUB_TOKEN}"
8+
codegen:
9+
generator: graphql-binding
10+
language: typescript
11+
input:
12+
schema: src/schema.ts
13+
output:
14+
binding: src/generated-binding.ts

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const resolvers = {
3838
},
3939
},
4040
// the following is needed to make interfaces, unions & custom scalars work
41-
...github.remoteResolvers(typeDefs),
41+
...github.getAbstractResolvers(typeDefs),
4242
}
4343

4444
const server = new GraphQLServer({ resolvers, typeDefs })

example/src/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
const { GitHub } = require('graphql-binding-github')
1+
const { Github } = require('../../dist/index')
22
const { GraphQLServer } = require('graphql-yoga')
33

4+
console.log({Github})
5+
46
const favoriteRepos = [
57
{ owner: 'graphcool', name: 'graphql-yoga' },
68
{ owner: 'graphql', name: 'graphql-js' },
79
]
810

911
const token = process.env.GITHUB_TOKEN || ''
10-
const github = new GitHub(token)
12+
const github = new Github(token)
1113

12-
const typeDefs = '.schemas/app.graphql'
14+
const typeDefs = './schemas/app.graphql'
1315
const resolvers = {
1416
Query: {
1517
hello: (parent, { name }) => `Hello ${name || 'World'}!`,
@@ -19,7 +21,7 @@ const resolvers = {
1921
)
2022
},
2123
},
22-
...github.remoteResolvers(typeDefs),
24+
...github.getAbstractResolvers(typeDefs),
2325
}
2426

2527
const server = new GraphQLServer({ resolvers, typeDefs })

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
"schema"
99
],
1010
"scripts": {
11-
"prepare": "npm run build",
12-
"build": "rm -rf dist && tsc -d",
11+
"prepare": "npm run build && cp src/schema.graphql dist/schema.graphql",
12+
"build": "rm -rf dist && graphql codegen && tsc -d",
1313
"test": "echo No tests yet"
1414
},
1515
"dependencies": {
1616
"apollo-link": "1.2.2",
17-
"apollo-link-http": "1.3.3",
17+
"apollo-link-http": "1.5.3",
1818
"cross-fetch": "2.1.1",
1919
"graphql": "0.13.2",
20-
"graphql-binding": "1.3.1",
21-
"graphql-tools": "2.21.0"
20+
"graphql-binding": "1.4.0-beta.23",
21+
"graphql-tools": "2.23.1"
2222
},
2323
"devDependencies": {
24+
"graphql-cli": "^2.16.0-beta.6",
2425
"@types/graphql": "0.13.1",
2526
"@types/node": "10.1.4",
2627
"typescript": "2.8.3"

0 commit comments

Comments
 (0)