import { createFetch } from 'relay-local-schema' ; import { Environment , Network , RecordSource , Store } from 'relay-runtime' ; import schema from './fixtures/schema' ; export function createFakeFetch ( ) { return createFetch ( { schema } ) ; } export function timeout ( delay ) { return new Promise ( ( resolve ) => { setTimeout ( resolve , delay ) ; } ) ; } export function createSyncEnvironment ( fetch = createFakeFetch ( ) , records ) { return new Environment ( { network : Network . create ( fetch ) , store : new Store ( new RecordSource ( records ) ) , } ) ; } export function createEnvironment ( fetch = createFakeFetch ( ) , records ? ) { return createSyncEnvironment ( async ( ... args ) => { await timeout ( 5 ) ; return fetch ( ... args ) ; } , records ) ; }