Skip to content

Commit 0ce319d

Browse files
committed
Passing ResolveInfo to globalIdField idFetcher
Passing ResolveInfo to globalIdField idFetcher give the opportunity to build an id using the `rootValue`. I think this can be very useful when you are working with multi-language application and need a simple and localized way to ensure Relay.Store consistent update.
1 parent 87d865e commit 0ce319d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/node/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ export function fromGlobalId(globalId: string): ResolvedGlobalId {
109109
*/
110110
export function globalIdField(
111111
typeName: string,
112-
idFetcher?: (object: any) => string
112+
idFetcher?: (object: 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) => toGlobalId(typeName, idFetcher ? idFetcher(obj) : obj.id)
118+
resolve: (obj,args,info) => toGlobalId(typeName, idFetcher ? idFetcher(obj,info) : obj.id)
119119
};
120120
}

0 commit comments

Comments
 (0)