Closed huan closed 6 years ago
# read() with exist id
05:09:10 SILL Apollo getApolloClient() connected
05:09:10 VERB Store constructor()
05:09:10 VERB HostieStore constructor()
05:09:10 VERB Store open()
05:09:10 VERB Store initSubscribeToMore(itemQuery)
05:09:10 VERB Store initSubscription(itemQuery)
05:09:10 VERB HostieStore create(newHostie={"name":"name-8217636","key":"key-8217636","ownerId":"cjf224evh00700131q0t5z4he"})
05:09:10 VERB Store mutationUpdateFn(mutationType=CREATED, mutationDataKey=createHostie)
05:09:10 SILL HostieStore create() apollo.mutate()
Unhandled error GraphQL error: Cannot return null for non-nullable type (line 13, column 3):
owner {
^ Error: GraphQL error: Cannot return null for non-nullable type (line 13, column 3):
owner {
^
at new ApolloError (/home/travis/build/Chatie/db/node_modules/apollo-client/errors/ApolloError.js:34:28)
at /home/travis/build/Chatie/db/node_modules/apollo-client/core/QueryManager.js:273:41
at /home/travis/build/Chatie/db/node_modules/apollo-client/core/QueryManager.js:659:17
at Array.forEach (<anonymous>)
at /home/travis/build/Chatie/db/node_modules/apollo-client/core/QueryManager.js:658:18
at Map.forEach (<anonymous>)
at QueryManager.broadcastQueries (/home/travis/build/Chatie/db/node_modules/apollo-client/core/QueryManager.js:653:22)
at Object.next (/home/travis/build/Chatie/db/node_modules/apollo-client/core/QueryManager.js:687:31)
at SubscriptionObserver.next (/home/travis/build/Chatie/db/node_modules/zen-observable/zen-observable.js:158:20)
at /home/travis/build/Chatie/db/node_modules/apollo-link-dedup/src/dedupLink.ts:60:43
05:09:10 VERB Store mutationUpdateFn(mutationType=CREATED, mutationDataKey=createHostie), (proxy, {data})
05:09:10 VERB Store mutationUpdateFn() call proxy.readQuery() before any query had been executed.
05:09:10 SILL HostieStore create() apollo.mutate() done
createHostie: { name: 'name-8217636',
__typename: 'Hostie',
key: 'key-8217636',
id: 'cjf224f2p007b013183ixz6qx',
note: null,
owner:
{ email: 'email-6952214@email.com',
id: 'cjf224evh00700131q0t5z4he',
name: 'name-6952214',
__typename: 'User' } }
05:09:10 VERB Store read(id=cjf224f2p007b013183ixz6qx)
05:09:10 SILL Store get itemDict()
not ok 7 Error: Store.read(id=cjf224f2p007b013183ixz6qx) not found!
---
operator: fail
at: Object.<anonymous> (/home/travis/build/Chatie/db/src/hostie/hostie-store.spec.ts:111:19)
stack: |-
Error: Error: Store.read(id=cjf224f2p007b013183ixz6qx) not found!
at Test.assert [as _assert] (/home/travis/build/Chatie/db/node_modules/tape/lib/test.js:225:54)
at Test.bound [as _assert] (/home/travis/build/Chatie/db/node_modules/tape/lib/test.js:77:32)
at Test.fail (/home/travis/build/Chatie/db/node_modules/tape/lib/test.js:318:10)
at Test.bound [as fail] (/home/travis/build/Chatie/db/node_modules/tape/lib/test.js:77:32)
at Object.<anonymous> (/home/travis/build/Chatie/db/src/hostie/hostie-store.spec.ts:111:19)
at Generator.throw (<anonymous>)
at rejected (/home/travis/build/Chatie/db/src/hostie/hostie-store.spec.ts:6:65)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
...
05:09:10 VERB Store close()
05:09:10 VERB Db close()
Finally, the CI turned green.
SOLUTION: It seems that the apollo-client might have some bug when we are running subscribeToMore() then with a mutate() at the same time. So we have to wait for the subscription initialized before we do mutate().
after we created the new item in the Store, the subscription need to be notified from the WebSocket, so we have to wait a while after the creation, or we will get an empty itemDict.
SOLUTION: wait for event loop to finished all queued tasksUPDATE: It seems that the apollo-client might have some bug when we are runningsubscribeToMore()
then with amutate()
at the same time. So we have to wait for thesubscription
initialized before we domutate()
.https://travis-ci.org/Chatie/db/builds/356676518