How to use the react-apollo.IntrospectionFragmentMatcher function in react-apollo

To help you get started, we’ve selected a few react-apollo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MainframeHQ / onyx / src / data / Apollo.js View on Github external
// @flow

import { ApolloClient, IntrospectionFragmentMatcher } from 'react-apollo'
import { SubscriptionClient } from 'subscriptions-transport-ws'

const WebSocket = window.require('ws')
const Store = window.require('electron-store')
const { is } = window.require('electron-util')
const fs = window.require('fs')

const store = new Store({ name: is.development ? 'onyx-dev' : 'onyx' })

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
          kind: 'UNION',
          name: 'MessageBlock',
          possibleTypes: [
            {
              name: 'MessageBlockText',
            },
            {
              name: 'MessageBlockFile',
            },
            {
              name: 'MessageBlockAction',
            },
github assembl / assembl / assembl / static2 / js / app / client.js View on Github external
import { ApolloClient, toIdValue, IntrospectionFragmentMatcher } from 'react-apollo';
import { createNetworkInterface } from 'apollo-upload-client';
import * as Sentry from '@sentry/browser';

import { getDiscussionSlug } from './utils/globalFunctions';
import { getFullPath } from './utils/routeMap';
import fetch from 'isomorphic-fetch'; // eslint-disable-line

const myFragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
          kind: 'INTERFACE',
          name: 'IdeaInterface',
          possibleTypes: [{ name: 'Idea' }, { name: 'Thematic' }]
        }
      ]
    }
  }
});

// The object id retrieved is already unique, it's actually
// ObjectType:primaryKey encoded in base64, so we define our
// own dataIdFromObject instead of using the default one `${o.__typename}:o.id`.
github MainframeHQ / onyx / packages / onyx-mobile / src / data / Apollo.js View on Github external
// @flow

import { IntrospectionFragmentMatcher } from 'react-apollo'
import ApolloClient, { createNetworkInterface } from 'apollo-client'
import { SubscriptionClient } from 'subscriptions-transport-ws'
import RNFS from 'react-native-fs'

import OnyxWebSocket from '../OnyxWebSocket'

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
          kind: 'UNION',
          name: 'MessageBlock',
          possibleTypes: [
            {
              name: 'MessageBlockText',
            },
            {
              name: 'MessageBlockFile',
            },
            {
              name: 'MessageBlockAction',
            },
github django-rea / rea-app / packages / store / configure.tsx View on Github external
const configureStore = async (initialState, history) => {
  const sagaMiddleware = createSagaMiddleware()

  const networkInterface = createNetworkInterface({ uri: apiUrl })

  const schemaMeta = await networkInterface.query({
    query: introspectionQuery,
  })

  const client = new ApolloClient({
    shouldBatch: true,
    networkInterface: networkInterface,
    fragmentMatcher: new IntrospectionFragmentMatcher({
      introspectionQueryResultData: schemaMeta.data,
    }),
  })

  const finalCreateStore = compose(
    applyMiddleware(
      client.middleware(),
      thunk,
      sagaMiddleware,
      routerMiddleware(history),
    ),
    browser ? persistState('auth') : (m) => m,
    devMiddlewares
  )(createStore)

  const store = finalCreateStore(reducer(client), initialState)
github staylor / graphql-wordpress / packages / apollo-wordpress / src / apollo / fragmentMatcher.js View on Github external
import { IntrospectionFragmentMatcher } from 'react-apollo';
import introspectionQueryResultData from '../../tools/fragmentMatcher.json';

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData,
});

export default fragmentMatcher;
github orbiting / crowdfunding-frontend / lib / initClient.js View on Github external
import { ApolloClient, createNetworkInterface, IntrospectionFragmentMatcher } from 'react-apollo'
import { API_BASE_URL, API_AUTHORIZATION_HEADER } from '../constants'

let apolloClient = null

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData: {
    __schema: {
      types: [
        {
          kind: 'UNION',
          name: 'Reward',
          possibleTypes: [
            {
              name: 'Goodie'
            },
            {
              name: 'MembershipType'
            }
          ]
        }
      ]