Skip to content

Commit

Permalink
version 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jellegerbrandy committed Sep 10, 2019
1 parent e9da76b commit 1ef9482
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 3 deletions.
5 changes: 5 additions & 0 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
schema: http://localhost:8000/subgraphs/name/daostack
generates:
./src/types.d.ts:
plugins:
- typescript
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/client",
"version": "0.2.6",
"version": "0.2.7",
"description": "",
"keywords": [],
"main": "dist/lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class Arc extends GraphNodeObserver {
ipfsProvider?: IPFSProvider
web3Provider?: string
web3ProviderRead?: string
}) {
}) {
super({
graphqlHttpProvider: options.graphqlHttpProvider,
graphqlWsProvider: options.graphqlWsProvider
Expand Down
78 changes: 78 additions & 0 deletions test/cache.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { first } from 'rxjs/operators'
// import { ApolloClient } from 'apollo-client'
// import gql from 'graphql-tag'
// import { Observable, Observer } from 'rxjs'
import { Arc } from '../src/arc'
// import { createApolloClient } from '../src/graphnode'
import { getContractAddressesFromMigration } from '../src/utils'
import { graphqlHttpProvider, graphqlWsProvider
// , mintSomeReputation, waitUntilTrue
} from './utils'

// function getClient() {
// const apolloClient = createApolloClient({
// graphqlHttpProvider,
// graphqlWsProvider
// })
// return apolloClient
// }

jest.setTimeout(20000)
/**
* Token test
*/
describe('apolloClient', () => {
// let client: any

it('pre-fetching DAOs works', async () => {
const arc = new Arc({
contractInfos: getContractAddressesFromMigration('private'),
graphqlHttpProvider,
graphqlWsProvider,
ipfsProvider: '',
web3Provider: 'ws://127.0.0.1:8545'
})

const client = arc.apolloClient
// get all DAOs
const daos = await arc.daos().pipe(first()).toPromise()
// @ts-ignore
console.log(client.cache.data.data)
// we should now be able to get data of individual DAOs without hitting the server
const p = arc.dao(daos[0].id).state({ fetchPolicy: 'cache-only'}).pipe(first()).toPromise()
expect(p).rejects.toThrow()

// now get all the DAOs with defailed data
await arc.daos({}, { fetchAllData: true }).pipe(first()).toPromise()
const dao = await arc.dao(daos[0].id).state({ fetchPolicy: 'cache-only'}).pipe(first()).toPromise()
// @ts-ignore
// console.log(client.cache.data.data)
console.log(dao.address)

//
const result = await arc.daos({ where: { name: dao.name}}, { fetchPolicy: 'cache-only'}).pipe(first()).toPromise()
console.log(result)

// const observable = arc.getObservable(query)
//
// const returnedData: object[] = []
//
// const subscription = observable.subscribe(
// (eventData: any) => {
// // Do something on receipt of the event
// returnedData.push(eventData.data)
// },
// (err: any) => {
// throw err
// }
// )
//
// await mintSomeReputation()
// await mintSomeReputation()
//
// await waitUntilTrue(() => returnedData.length >= 2 )
// expect(cntr).toEqual(3)
// subscription.unsubscribe()
})

})

0 comments on commit 1ef9482

Please sign in to comment.