General finding

Subgraphs

All Apollo configurations follow a similar pattern:

import { ApolloClient, ApolloQueryResult } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { RetryLink } from 'apollo-link-retry'
import { WebSocketLink } from 'apollo-link-ws'

export function createApolloClient(options: {
  graphqlHttpProvider: string,
  graphqlWsProvider: string,
  retryLink?: any // apollo retry link instance
}) {
  const httpLink = new HttpLink({
    credentials: 'same-origin',
    fetch,
    uri: options.graphqlHttpProvider
  })

  const wsLink = new WebSocketLink({
    options: {
      reconnect: true
    },
    uri: options.graphqlWsProvider,
    webSocketImpl: WebSocket
  })
}

DAOStack

DAOStack Client

Arc class initialization overview using ipfsClient and graphnode modules.

import { GraphNodeObserver, IApolloQueryOptions } from './graphnode'
import { IPFSClient } from './ipfsClient'
const Web3 = require('web3')

/**
 * The Arc class holds all configuration.
 * Any useage of the library typically will start with instantiating a new Arc instance
 * @return an instance of Arc
 */
export class Arc extends GraphNodeObserver {
  public web3Provider: Web3Provider = ''
  public web3ProviderRead: Web3Provider = ''
  public ipfsProvider: IPFSProvider

  public ipfs: any
  public web3: typeof Web3
  public web3Read: typeof Web3 // if provided, arc will read all data from this provider

  constructor(options: {
    graphqlHttpProvider?: string
    graphqlWsProvider?: string
    ipfsProvider?: IPFSProvider
    web3Provider?: string
    web3ProviderRead?: string
    /** this function will be called before a query is sent to the graphql provider */
    graphqlPrefetchHook?: (query: any) => void
    /** determines whether a query should subscribe to updates from the graphProvider. Default is true.  */
    graphqlSubscribeToQueries?: boolean
    /** an apollo-retry-link instance as <https://www.apollographql.com/docs/link/links/retry/#default-configuration> */
    graphqlRetryLink?: any,
    graphqlErrHandler?: any
  }) {
    super({
      errHandler: options.graphqlErrHandler,
      graphqlHttpProvider: options.graphqlHttpProvider,
      graphqlSubscribeToQueries: options.graphqlSubscribeToQueries,
      graphqlWsProvider: options.graphqlWsProvider,
      prefetchHook: options.graphqlPrefetchHook,
      retryLink: options.graphqlRetryLink
    })
    this.ipfsProvider = options.ipfsProvider || ''

    if (options.web3Provider) {
      this.web3 = new Web3(options.web3Provider)
    }
    if (options.web3ProviderRead) {
      this.web3Read = new Web3(options.web3ProviderRead)
    } else {
      this.web3Read = this.web3
    }

    if (this.ipfsProvider) {
      this.ipfs = new IPFSClient(this.ipfsProvider)
    }

    // by default, we subscribe to queries
    if (options.graphqlSubscribeToQueries === undefined) {
      options.graphqlSubscribeToQueries = true
    }
  }
	...
}

Reference: arc.ts

Overview of DAOStack tech stack on DAOStack hackers kit.


AirSwap

Interesting example of ipfs using ipfs-mini

It use AirSwap and Infura nodes, Pinata to pin and Cloudfare to fetch content.