Skip to content

Commit

Permalink
Remove .compile(...) from the MockRelayEnvironment
Browse files Browse the repository at this point in the history
Reviewed By: josephsavona

Differential Revision: D14509833

fbshipit-source-id: 8424675803fa11754cd6900cb286e953ef2f7896
  • Loading branch information
alunyov authored and facebook-github-bot committed Mar 18, 2019
1 parent 6ff8178 commit fdff791
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions packages/relay-test-utils/RelayModernMockEnvironment.js
Expand Up @@ -9,9 +9,6 @@

'use strict';

const RelayModernTestUtils = require('./RelayModernTestUtils');
const RelayTestSchema = require('./RelayTestSchema');

const areEqual = require('areEqual');
const invariant = require('invariant');

Expand Down Expand Up @@ -70,18 +67,14 @@ function mockObservableMethod(object, key) {
*
* Helpers are available as `environment.mock.<helper>`:
*
* - `compile(text: string): {[queryName]: Query}`: Create a query.
* - `isLoading(query, variables): boolean`: Determine whether the given query
* is currently being loaded (not yet rejected/resolved).
* - `reject(query, error: Error): void`: Reject a query that has been fetched
* by the environment.
* - `resolve(query, payload: PayloadData): void`: Resolve a query that has been
* fetched by the environment.
*/
function createMockEnvironment(options?: {
schema?: ?GraphQLSchema,
handlerProvider?: ?HandlerProvider,
}) {
function createMockEnvironment(options?: {handlerProvider?: ?HandlerProvider}) {
const {
RecordSource,
Store,
Expand All @@ -90,7 +83,6 @@ function createMockEnvironment(options?: {
Environment,
Network,
} = require('relay-runtime');
const schema = options && options.schema;
const handlerProvider = options && options.handlerProvider;
const source = new RecordSource();
const store = new Store(source);
Expand Down Expand Up @@ -165,15 +157,6 @@ function createMockEnvironment(options?: {
cache.clear();
};

// Helper to compile a query with the given schema (or the test schema by
// default).
const compile = text => {
return RelayModernTestUtils.generateAndCompile(
text,
schema || RelayTestSchema,
);
};

// Helper to determine if a given query/variables pair is pending
const isLoading = (request, variables, cacheConfig) => {
return pendingRequests.some(
Expand Down Expand Up @@ -241,7 +224,6 @@ function createMockEnvironment(options?: {
environment.mock = {
cachePayload,
clearCache,
compile,
isLoading,
reject,
resolve,
Expand Down

0 comments on commit fdff791

Please sign in to comment.