@urql/exchange-graphcache
Advanced tools
Comparing version 1.0.0-rc.8 to 1.0.0-rc.9
@@ -11,2 +11,6 @@ # Changelog | ||
## [v1.0.0-rc.9](https://github.com/FormidableLabs/urql-exchange-graphcache/compare/v1.0.0-rc.8...v1.0.0-rc.9) | ||
- ⚠ Fix optimistic updates by upgrading to Pessimism `1.1.3` (see [#81](https://github.com/FormidableLabs/urql-exchange-graphcache/pull/81)) | ||
## [v1.0.0-rc.8](https://github.com/FormidableLabs/urql-exchange-graphcache/compare/v1.0.0-rc.7...v1.0.0-rc.8) | ||
@@ -13,0 +17,0 @@ |
{ | ||
"name": "@urql/exchange-graphcache", | ||
"version": "1.0.0-rc.8", | ||
"version": "1.0.0-rc.9", | ||
"description": "A normalized and configurable cache exchange for urql", | ||
@@ -79,3 +79,3 @@ "repository": "https://github.com/FormidableLabs/urql-exchange-graphcache", | ||
"fast-json-stable-stringify": "^2.0.0", | ||
"pessimism": "^1.1.1", | ||
"pessimism": "^1.1.3", | ||
"tiny-invariant": "^1.0.6", | ||
@@ -82,0 +82,0 @@ "wonka": "^3.2.1" |
import gql from 'graphql-tag'; | ||
import { query, write } from '../operations'; | ||
import { query, write, writeOptimistic } from '../operations'; | ||
import { Store } from '../store'; | ||
@@ -179,3 +179,3 @@ import { Data } from '../types'; | ||
it('Respects property-level resolvers when given', () => { | ||
it('respects property-level resolvers when given', () => { | ||
const store = new Store(undefined, undefined, { | ||
@@ -267,1 +267,84 @@ Mutation: { | ||
}); | ||
it('correctly resolves optimistic updates on Relay schemas', () => { | ||
const store = new Store(undefined, undefined, undefined, { | ||
updateItem: variables => ({ | ||
__typename: 'UpdateItemPayload', | ||
item: { | ||
__typename: 'Item', | ||
id: variables.id as string, | ||
name: 'Offline', | ||
}, | ||
}), | ||
}); | ||
const queryData = { | ||
__typename: 'Query', | ||
root: { | ||
__typename: 'Root', | ||
id: 'root', | ||
items: { | ||
__typename: 'ItemConnection', | ||
edges: [ | ||
{ | ||
__typename: 'ItemEdge', | ||
node: { | ||
__typename: 'Item', | ||
id: '1', | ||
name: 'Number One', | ||
}, | ||
}, | ||
{ | ||
__typename: 'ItemEdge', | ||
node: { | ||
__typename: 'Item', | ||
id: '2', | ||
name: 'Number Two', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const getRoot = gql` | ||
query GetRoot { | ||
root { | ||
__typename | ||
id | ||
items { | ||
__typename | ||
edges { | ||
__typename | ||
node { | ||
__typename | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
const updateItem = gql` | ||
mutation UpdateItem($id: ID!) { | ||
updateItem(id: $id) { | ||
__typename | ||
item { | ||
__typename | ||
id | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
write(store, { query: getRoot }, queryData); | ||
writeOptimistic(store, { query: updateItem, variables: { id: '2' } }, 1); | ||
store.clearOptimistic(1); | ||
const queryRes = query(store, { query: getRoot }); | ||
expect(queryRes.partial).toBe(false); | ||
expect(queryRes.data).not.toBe(null); | ||
}); |
@@ -304,13 +304,18 @@ import { DocumentNode } from 'graphql'; | ||
it('embedded invalid object on entity', () => { | ||
it('embedded objects on entities', () => { | ||
expectCacheIntegrity({ | ||
query: gql` | ||
{ | ||
__typename | ||
item { | ||
user { | ||
__typename | ||
id | ||
author { | ||
posts { | ||
__typename | ||
name | ||
edges { | ||
__typename | ||
node { | ||
__typename | ||
id | ||
} | ||
} | ||
} | ||
@@ -322,8 +327,16 @@ } | ||
__typename: 'Query', | ||
item: { | ||
__typename: 'Item', | ||
user: { | ||
__typename: 'User', | ||
id: 1, | ||
author: { | ||
__typename: 'Author', | ||
name: 'Stanley', | ||
posts: { | ||
__typename: 'PostsConnection', | ||
edges: [ | ||
{ | ||
__typename: 'PostsEdge', | ||
node: { | ||
__typename: 'Post', | ||
id: 1, | ||
}, | ||
}, | ||
], | ||
}, | ||
@@ -334,32 +347,1 @@ }, | ||
}); | ||
it('embedded object on entity', () => { | ||
expectCacheIntegrity({ | ||
query: gql` | ||
{ | ||
__typename | ||
item { | ||
__typename | ||
id | ||
author { | ||
__typename | ||
id | ||
name | ||
} | ||
} | ||
} | ||
`, | ||
data: { | ||
__typename: 'Query', | ||
item: { | ||
__typename: 'Item', | ||
id: 1, | ||
author: { | ||
__typename: 'Author', | ||
id: 1, | ||
name: 'Stanley', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
578526
6448
Updatedpessimism@^1.1.3