Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

(graphcahce) - fix resolver types (#927)

* fix typings by allowing for an object in a resolver

* add changeset and correct test

* add null and move into separate type

* Update .changeset/hungry-cycles-kiss.md

Co-authored-by: Phil Pluckthun <phil@kitten.sh>

authored by

Jovi De Croock
Phil Pluckthun
and committed by
GitHub
4ec00883 03d98319

+16 -1
+5
.changeset/hungry-cycles-kiss.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Fix return type for resolvers to allow data objects to be returned with `__typename` as expected
+4
exchanges/graphcache/src/cacheExchange.test.ts
··· 1264 1264 pipe( 1265 1265 cacheExchange({ 1266 1266 resolvers: { 1267 + Query: { 1268 + // TS-check 1269 + author: (_parent, args) => ({ __typename: 'Author', id: args.id }), 1270 + }, 1267 1271 Author: { 1268 1272 name: parent => { 1269 1273 called.push(parent.name);
+7 -1
exchanges/graphcache/src/types.ts
··· 122 122 ): void; 123 123 } 124 124 125 + type ResolverResult = 126 + | DataField 127 + | (DataFields & { __typename?: string }) 128 + | null 129 + | undefined; 130 + 125 131 // Cache resolvers are user-defined to overwrite an entity field result 126 132 export type Resolver = ( 127 133 parent: Data, 128 134 args: Variables, 129 135 cache: Cache, 130 136 info: ResolveInfo 131 - ) => DataField | undefined; 137 + ) => ResolverResult; 132 138 133 139 export interface ResolverConfig { 134 140 [typeName: string]: {