Skip to content

Commit dda3230

Browse files
committed
Adding migration guide
1 parent 5afa5c1 commit dda3230

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

MIGRATE.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Upgrade from v1 to v2
2+
The only difference between v1 and v2 is that we added use of [context](https://golang.org/pkg/context).
3+
4+
```diff
5+
- loader.Load(key string) Thunk
6+
+ loader.Load(ctx context.Context, key string) Thunk
7+
- loader.LoadMany(keys []string) ThunkMany
8+
+ loader.LoadMany(ctx context.Context, keys []string) ThunkMany
9+
```
10+
11+
```diff
12+
- type BatchFunc func([]string) []*Result
13+
+ type BatchFunc func(context.Context, []string) []*Result
14+
```
15+
16+
## Upgrade from v2 to v3
17+
```diff
18+
// dataloader.Interface as added context.Context to methods
19+
- loader.Prime(key string, value interface{}) Interface
20+
+ loader.Prime(ctx context.Context, key string, value interface{}) Interface
21+
- loader.Clear(key string) Interface
22+
+ loader.Clear(ctx context.Context, key string) Interface
23+
```
24+
25+
```diff
26+
// cache interface as added context.Context to methods
27+
type Cache interface {
28+
- Get(string) (Thunk, bool)
29+
+ Get(context.Context, string) (Thunk, bool)
30+
- Set(string, Thunk)
31+
+ Set(context.Context, string, Thunk)
32+
- Delete(string) bool
33+
+ Delete(context.Context, string) bool
34+
Clear()
35+
}
36+
```
37+
38+
## Upgrade from v3 to v4
39+
```diff
40+
// dataloader.Interface as now allows interace{} as key rather than string
41+
- loader.Load(context.Context, key string) Thunk
42+
+ loader.Load(ctx context.Context, key interface{}) Thunk
43+
- loader.LoadMany(context.Context, key []string) ThunkMany
44+
+ loader.LoadMany(ctx context.Context, keys []interface{}) ThunkMany
45+
- loader.Prime(context.Context, key string, value interface{}) Interface
46+
+ loader.Prime(ctx context.Context, key interface{}, value interface{}) Interface
47+
- loader.Clear(context.Context, key string) Interface
48+
+ loader.Clear(ctx context.Context, key interface{}) Interface
49+
```
50+
51+
```diff
52+
// cache interface now allows interface{} as key instead of string
53+
type Cache interface {
54+
- Get(context.Context, string) (Thunk, bool)
55+
+ Get(context.Context, interface{}) (Thunk, bool)
56+
- Set(context.Context, string, Thunk)
57+
+ Set(context.Context, interface{}, Thunk)
58+
- Delete(context.Context, string) bool
59+
+ Delete(context.Context, interface{}) bool
60+
Clear()
61+
}
62+
```
63+
64+
## Upgrade from v4 to v5
65+
```diff
66+
// dataloader.Interface as now allows interace{} as key rather than string
67+
- loader.Load(context.Context, key interface{}) Thunk
68+
+ loader.Load(ctx context.Context, key Key) Thunk
69+
- loader.LoadMany(context.Context, key []interface{}) ThunkMany
70+
+ loader.LoadMany(ctx context.Context, keys Keys) ThunkMany
71+
- loader.Prime(context.Context, key interface{}, value interface{}) Interface
72+
+ loader.Prime(ctx context.Context, key Key, value interface{}) Interface
73+
- loader.Clear(context.Context, key interface{}) Interface
74+
+ loader.Clear(ctx context.Context, key Key) Interface
75+
```
76+
77+
```diff
78+
// cache interface now allows interface{} as key instead of string
79+
type Cache interface {
80+
- Get(context.Context, interface{}) (Thunk, bool)
81+
+ Get(context.Context, Key) (Thunk, bool)
82+
- Set(context.Context, interface{}, Thunk)
83+
+ Set(context.Context, Key, Thunk)
84+
- Delete(context.Context, interface{}) bool
85+
+ Delete(context.Context, Key) bool
86+
Clear()
87+
}
88+
```

0 commit comments

Comments
 (0)