Last active
September 26, 2016 13:01
-
-
Save steveluscher/ffc1dfefbb10ad280c8a4c520a5c201c to your computer and use it in GitHub Desktop.
Revisions
-
steveluscher revised this gist
May 23, 2016 . 1 changed file with 45 additions and 37 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,51 +4,59 @@ This version of `graphql-js` introduces a breaking change to the method signatur Previously, `resolve()` had this method signature: ```js type GraphQLResolveInfo = { fieldName: string, fieldASTs: Array<Field>, returnType: GraphQLOutputType, parentType: GraphQLCompositeType, schema: GraphQLSchema, fragments: { [fragmentName: string]: FragmentDefinition }, rootValue: mixed, operation: OperationDefinition, variableValues: { [variableName: string]: mixed }, }; resolve( source: mixed, args: {[argName: string]: mixed}, info: GraphQLResolveInfo ): mixed ``` Typically, when you wanted to thread request or other context-specific information down to the resolve functions, you might have included it in `rootValue` when calling `graphql()`: ```js // Pre 0.6.0 graphql(req => { return { rootValue: {viewer: req.userID}, schema, }; }); ``` Now there exists a bonafide `context` property that you can set for exactly this purpose: ```js // New in 0.6.0 graphql(req => { return { context: {viewer: req.userID}, // NEW schema, }; }); ``` `graphql-js` 0.6.0 will make this `context` prop available to each one of your `resolve()` methods as the third argument: ```js resolve( source: mixed, args: {[argName: string]: mixed}, context: mixed, // NEW info: GraphQLResolveInfo // MOVED ): mixed ``` Note that the `info` argument has moved to the fourth position. Anyone previously making use of the `info` argument will have to update the method signatures of their `resolve()` methods. -
steveluscher created this gist
May 23, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ # GraphQL 0.6.0 migration guide This version of `graphql-js` introduces a breaking change to the method signature of the `resolve()` method. Previously, `resolve()` had this method signature: type GraphQLResolveInfo = { fieldName: string, fieldASTs: Array<Field>, returnType: GraphQLOutputType, parentType: GraphQLCompositeType, schema: GraphQLSchema, fragments: { [fragmentName: string]: FragmentDefinition }, rootValue: mixed, operation: OperationDefinition, variableValues: { [variableName: string]: mixed }, }; resolve( source: mixed, args: {[argName: string]: mixed}, info: GraphQLResolveInfo ): mixed Typically, when you wanted to thread request or other context-specific information down to the resolve functions, you might have included it in `rootValue` when calling `graphql()`: // Pre 0.6.0 graphql(req => { return { rootValue: {viewer: req.userID}, schema, }; }); Now there exists a bonafide `context` property that you can set for exactly this purpose: // New in 0.6.0 graphql(req => { return { context: {viewer: req.userID}, // NEW schema, }; }); `graphql-js` 0.6.0 will make this `context` prop available to each one of your `resolve()` methods as the third argument: resolve( source: mixed, args: {[argName: string]: mixed}, context: mixed, // NEW info: GraphQLResolveInfo // MOVED ): mixed Note that the `info` argument has moved to the fourth position. Anyone previously making use of the `info` argument will have to update the method signatures of their `resolve()` methods.