Skip to content

Commit 784b227

Browse files
committed
Merge pull request #74 from wincent/graphql-5.0-compat
Make compatible with graphql-js v0.5.0
2 parents 84a1268 + 4ed95bd commit 784b227

File tree

8 files changed

+22
-16
lines changed

8 files changed

+22
-16
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"babel-runtime": "~5.8.3"
5050
},
5151
"peerDependencies": {
52-
"graphql": "~0.4.2"
52+
"graphql": "~0.5.0"
5353
},
5454
"devDependencies": {
5555
"babel": "5.8.3",
@@ -60,7 +60,7 @@
6060
"coveralls": "2.11.8",
6161
"eslint": "2.2.0",
6262
"flow-bin": "0.22.1",
63-
"graphql": "0.4.18",
63+
"graphql": "0.5.0",
6464
"isparta": "3.0.3",
6565
"mocha": "2.2.5",
6666
"sane": "1.1.3"

src/__tests__/starWarsMutationTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Star Wars mutations', () => {
5050
clientMutationId: 'abcde',
5151
}
5252
};
53-
var result = await graphql(StarWarsSchema, mutation, null, params);
53+
var result = await graphql(StarWarsSchema, mutation, null, null, params);
5454
expect(result).to.deep.equal({ data: expected });
5555
});
5656
});

src/node/__tests__/global.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ var queryType = new GraphQLObjectType({
130130
});
131131

132132
var schema = new GraphQLSchema({
133-
query: queryType
133+
query: queryType,
134+
types: [userType, photoType, postType]
134135
});
135136

136137
describe('global ID fields', () => {

src/node/__tests__/node.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var photoData = {
4848
};
4949

5050
var {nodeField, nodeInterface} = nodeDefinitions(
51-
(id, info) => {
51+
(id, context, info) => {
5252
expect(info.schema).to.equal(schema);
5353
if (userData[id]) {
5454
return userData[id];
@@ -99,7 +99,8 @@ var queryType = new GraphQLObjectType({
9999
});
100100

101101
var schema = new GraphQLSchema({
102-
query: queryType
102+
query: queryType,
103+
types: [userType, photoType]
103104
});
104105

105106
describe('Node interface and fields', () => {

src/node/__tests__/nodeasync.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ var queryType = new GraphQLObjectType({
6464
});
6565

6666
var schema = new GraphQLSchema({
67-
query: queryType
67+
query: queryType,
68+
types: [userType]
6869
});
6970

7071
describe('Node interface and fields with async object fetcher', () => {

src/node/__tests__/plural.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var queryType = new GraphQLObjectType({
4242
description: 'Map from a username to the user',
4343
inputType: GraphQLString,
4444
outputType: userType,
45-
resolveSingleInput: (username, {rootValue: {lang}}) => ({
45+
resolveSingleInput: (username, context, {rootValue: {lang}}) => ({
4646
username: username,
4747
url: 'www.facebook.com/' + username + '?lang=' + lang
4848
})

src/node/node.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type typeResolverFn = (object: any) => ?GraphQLObjectType |
4444
* interface without a provided `resolveType` method.
4545
*/
4646
export function nodeDefinitions(
47-
idFetcher: ((id: string, info: GraphQLResolveInfo) => any),
47+
idFetcher: ((id: string, context: any, info: GraphQLResolveInfo) => any),
4848
typeResolver?: ?typeResolverFn
4949
): GraphQLNodeDefinitions {
5050
var nodeInterface = new GraphQLInterfaceType({
@@ -69,7 +69,7 @@ export function nodeDefinitions(
6969
description: 'The ID of an object'
7070
}
7171
},
72-
resolve: (obj, {id}, info) => idFetcher(id, info)
72+
resolve: (obj, {id}, context, info) => idFetcher(id, context, info),
7373
};
7474

7575
return {nodeInterface, nodeField};
@@ -109,15 +109,15 @@ export function fromGlobalId(globalId: string): ResolvedGlobalId {
109109
*/
110110
export function globalIdField(
111111
typeName?: ?string,
112-
idFetcher?: (object: any, info: GraphQLResolveInfo) => string
112+
idFetcher?: (object: any, context: any, info: GraphQLResolveInfo) => string
113113
): GraphQLFieldConfig {
114114
return {
115115
name: 'id',
116116
description: 'The ID of an object',
117117
type: new GraphQLNonNull(GraphQLID),
118-
resolve: (obj, args, info) => toGlobalId(
118+
resolve: (obj, args, context, info) => toGlobalId(
119119
typeName || info.parentType.name,
120-
idFetcher ? idFetcher(obj, info) : obj.id
120+
idFetcher ? idFetcher(obj, context, info) : obj.id
121121
)
122122
};
123123
}

src/node/plural.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ type PluralIdentifyingRootFieldConfig = {
2424
argName: string,
2525
inputType: GraphQLInputType,
2626
outputType: GraphQLOutputType,
27-
resolveSingleInput: (input: any, info: GraphQLResolveInfo) => ?any,
27+
resolveSingleInput:
28+
(input: any, context: any, info: GraphQLResolveInfo) => ?any,
2829
description?: ?string,
2930
};
3031

@@ -45,10 +46,12 @@ export function pluralIdentifyingRootField(
4546
description: config.description,
4647
type: new GraphQLList(config.outputType),
4748
args: inputArgs,
48-
resolve: (obj, args, info) => {
49+
resolve: (obj, args, context, info) => {
4950
var inputs = args[config.argName];
5051
return Promise.all(inputs.map(
51-
input => Promise.resolve(config.resolveSingleInput(input, info))
52+
input => Promise.resolve(
53+
config.resolveSingleInput(input, context, info)
54+
)
5255
));
5356
}
5457
};

0 commit comments

Comments
 (0)