-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9da76b
commit 1ef9482
Showing
5 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
|
||
}) |