Repository: FormidableLabs/urql
Pull request #177 (2019-02-12 21:52:53)

Move files around


Patch:
diff --git a/src/lib/client.ts b/src/client.ts
similarity index 97%
rename from src/lib/client.ts
rename to src/client.ts
index 10811064..b75eb589 100755
--- a/src/lib/client.ts
+++ b/src/client.ts
@@ -1,6 +1,6 @@
 import { filter, makeSubject, onStart, pipe, share, Source, take } from 'wonka';
-import { composeExchanges, defaultExchanges } from '../exchanges';
-import { hashString } from './hash';
+import { composeExchanges, defaultExchanges } from './exchanges';
+import { hashString } from './utils';
 
 import {
   Exchange,
@@ -12,7 +12,7 @@ import {
   OperationContext,
   OperationResult,
   OperationType,
-} from '../types';
+} from './types';
 
 /** Options for configuring the URQL [client]{@link Client}. */
 export interface ClientOptions {
diff --git a/src/react/Mutation.tsx b/src/components/Mutation.tsx
similarity index 91%
rename from src/react/Mutation.tsx
rename to src/components/Mutation.tsx
index a53a625e..f2989077 100644
--- a/src/react/Mutation.tsx
+++ b/src/components/Mutation.tsx
@@ -1,7 +1,8 @@
 import React, { Component, FC, ReactNode } from 'react';
 import { pipe, toPromise } from 'wonka';
-import { Client, CombinedError, createMutation } from '../lib';
-import { Consumer } from './context';
+import { Client } from '../client';
+import { Consumer } from '../context';
+import { CombinedError, createMutation } from '../utils';
 
 interface MutationHandlerProps {
   client: Client;
diff --git a/src/react/Query.tsx b/src/components/Query.tsx
similarity index 92%
rename from src/react/Query.tsx
rename to src/components/Query.tsx
index 8678d85d..903fd2d6 100644
--- a/src/react/Query.tsx
+++ b/src/components/Query.tsx
@@ -1,7 +1,8 @@
 import React, { Component, FC, ReactNode } from 'react';
 import { pipe, subscribe } from 'wonka';
-import { Client, CombinedError, createQuery } from '../lib';
-import { Consumer } from './context';
+import { Client } from '../client';
+import { Consumer } from '../context';
+import { CombinedError, createQuery } from '../utils';
 
 interface QueryHandlerProps {
   client: Client;
diff --git a/src/react/Subscription.tsx b/src/components/Subscription.tsx
similarity index 92%
rename from src/react/Subscription.tsx
rename to src/components/Subscription.tsx
index 7a391578..f3456c9e 100644
--- a/src/react/Subscription.tsx
+++ b/src/components/Subscription.tsx
@@ -1,7 +1,8 @@
 import React, { Component, FC, ReactNode } from 'react';
 import { pipe, subscribe } from 'wonka';
-import { Client, CombinedError, createSubscription } from '../lib';
-import { Consumer } from './context';
+import { Client } from '../client';
+import { Consumer } from '../context';
+import { CombinedError, createSubscription } from '../utils';
 
 interface SubscriptionHandlerProps {
   client: Client;
diff --git a/src/react/__snapshots__/Mutation.test.tsx.snap b/src/components/__snapshots__/Mutation.test.tsx.snap
similarity index 100%
rename from src/react/__snapshots__/Mutation.test.tsx.snap
rename to src/components/__snapshots__/Mutation.test.tsx.snap
diff --git a/src/react/__snapshots__/Query.test.tsx.snap b/src/components/__snapshots__/Query.test.tsx.snap
similarity index 100%
rename from src/react/__snapshots__/Query.test.tsx.snap
rename to src/components/__snapshots__/Query.test.tsx.snap
diff --git a/src/components/index.ts b/src/components/index.ts
new file mode 100644
index 00000000..dba6c3fb
--- /dev/null
+++ b/src/components/index.ts
@@ -0,0 +1,7 @@
+// Render Props
+export { Mutation } from './Mutation';
+export { Query } from './Query';
+export { Subscription } from './Subscription';
+
+// Additional tools (advanced)
+export { Context, Consumer, Provider } from '../context';
diff --git a/src/react/context.test.ts b/src/context.test.ts
similarity index 100%
rename from src/react/context.test.ts
rename to src/context.test.ts
diff --git a/src/react/context.ts b/src/context.ts
similarity index 88%
rename from src/react/context.ts
rename to src/context.ts
index 41ed741f..9396a2c5 100644
--- a/src/react/context.ts
+++ b/src/context.ts
@@ -1,5 +1,5 @@
 import createContext from 'create-react-context';
-import { Client, createClient } from '../lib/client';
+import { Client, createClient } from './client';
 
 // We assume some default options here; mainly not to actually be used
 // but not to error catastrophically if someone is just playing around
diff --git a/src/exchanges/cache.ts b/src/exchanges/cache.ts
index c8188412..55d56de9 100755
--- a/src/exchanges/cache.ts
+++ b/src/exchanges/cache.ts
@@ -1,8 +1,8 @@
 import { filter, map, merge, pipe, share, tap } from 'wonka';
 
-import { Client } from '../lib/client';
-import { formatTypeNames, gankTypeNamesFromResponse } from '../lib/typenames';
+import { Client } from '../client';
 import { Exchange, Operation, OperationResult } from '../types';
+import { formatTypeNames, gankTypeNamesFromResponse } from '../utils/typenames';
 
 type ResultCache = Map<string, OperationResult>;
 interface OperationCache {
diff --git a/src/exchanges/compose.ts b/src/exchanges/compose.ts
index 505ddbc4..587aac11 100644
--- a/src/exchanges/compose.ts
+++ b/src/exchanges/compose.ts
@@ -1,6 +1,5 @@
 import { map, pipe } from 'wonka';
-
-import { Client } from '../lib/client';
+import { Client } from '../client';
 import { Exchange, ExchangeIO, OperationResult } from '../types';
 
 /** This is always the last exchange in the chain; No operation should ever reach it */
diff --git a/src/exchanges/fetch.ts b/src/exchanges/fetch.ts
index 9ab056e8..31f373e6 100755
--- a/src/exchanges/fetch.ts
+++ b/src/exchanges/fetch.ts
@@ -1,6 +1,6 @@
 import { filter, make, merge, mergeMap, pipe, share, takeUntil } from 'wonka';
-import { CombinedError } from '../lib/error';
 import { Exchange, Operation, OperationResult } from '../types';
+import { CombinedError } from '../utils/error';
 
 /** A default exchange for fetching GraphQL requests. */
 export const fetchExchange: Exchange = ({ forward }) => {
diff --git a/src/exchanges/subscription.ts b/src/exchanges/subscription.ts
index 4d31697b..40ca58ff 100644
--- a/src/exchanges/subscription.ts
+++ b/src/exchanges/subscription.ts
@@ -9,7 +9,7 @@ import {
   takeUntil,
 } from 'wonka';
 
-import { CombinedError } from '../lib/error';
+import { CombinedError } from '../utils/error';
 
 import {
   Exchange,
diff --git a/src/react/__snapshots__/useMutation.test.tsx.snap b/src/hooks/__snapshots__/useMutation.test.tsx.snap
similarity index 100%
rename from src/react/__snapshots__/useMutation.test.tsx.snap
rename to src/hooks/__snapshots__/useMutation.test.tsx.snap
diff --git a/src/react/__snapshots__/useQuery.test.tsx.snap b/src/hooks/__snapshots__/useQuery.test.tsx.snap
similarity index 100%
rename from src/react/__snapshots__/useQuery.test.tsx.snap
rename to src/hooks/__snapshots__/useQuery.test.tsx.snap
diff --git a/src/react/__snapshots__/useSubscription.test.tsx.snap b/src/hooks/__snapshots__/useSubscription.test.tsx.snap
similarity index 100%
rename from src/react/__snapshots__/useSubscription.test.tsx.snap
rename to src/hooks/__snapshots__/useSubscription.test.tsx.snap
diff --git a/src/hooks/index.ts b/src/hooks/index.ts
new file mode 100644
index 00000000..58b57faa
--- /dev/null
+++ b/src/hooks/index.ts
@@ -0,0 +1,3 @@
+export * from './useMutation';
+export * from './useQuery';
+export * from './useSubscription';
diff --git a/src/react/useMutation.ts b/src/hooks/useMutation.ts
similarity index 90%
rename from src/react/useMutation.ts
rename to src/hooks/useMutation.ts
index 005be5b5..9abbdd56 100644
--- a/src/react/useMutation.ts
+++ b/src/hooks/useMutation.ts
@@ -1,7 +1,7 @@
 import { useContext, useState } from 'react';
 import { pipe, toPromise } from 'wonka';
-import { CombinedError, createMutation } from '../lib';
-import { Context } from './context';
+import { Context } from '../context';
+import { CombinedError, createMutation } from '../utils';
 
 interface UseMutationState<T> {
   fetching: boolean;
diff --git a/src/react/useQuery.ts b/src/hooks/useQuery.ts
similarity index 92%
rename from src/react/useQuery.ts
rename to src/hooks/useQuery.ts
index 4ebb9683..fecbb428 100644
--- a/src/react/useQuery.ts
+++ b/src/hooks/useQuery.ts
@@ -1,7 +1,7 @@
 import { useContext, useEffect, useState } from 'react';
 import { pipe, subscribe } from 'wonka';
-import { CombinedError, createQuery } from '../lib';
-import { Context } from './context';
+import { Context } from '../context';
+import { CombinedError, createQuery } from '../utils';
 
 interface UseQueryArgs {
   query: string;
diff --git a/src/react/useSubscription.ts b/src/hooks/useSubscription.ts
similarity index 93%
rename from src/react/useSubscription.ts
rename to src/hooks/useSubscription.ts
index df96270f..b3b5ac9c 100644
--- a/src/react/useSubscription.ts
+++ b/src/hooks/useSubscription.ts
@@ -1,7 +1,7 @@
 import { useContext, useEffect, useState } from 'react';
 import { pipe, subscribe } from 'wonka';
-import { CombinedError, createQuery } from '../lib';
-import { Context } from './context';
+import { Context } from '../context';
+import { CombinedError, createQuery } from '../utils';
 
 interface UseSubscriptionArgs {
   query: string;
diff --git a/src/index.ts b/src/index.ts
index 95b85f92..ed207f75 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,4 +1,6 @@
+export * from './client';
+export * from './components';
 export * from './exchanges';
-export * from './lib';
-export * from './react';
+export * from './hooks';
 export * from './types';
+export * from './utils';
diff --git a/src/react/index.ts b/src/react/index.ts
deleted file mode 100644
index 316df522..00000000
--- a/src/react/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// Hooks
-export { useMutation } from './useMutation';
-export { useQuery } from './useQuery';
-export { useSubscription } from './useSubscription';
-
-// Render Props
-export { Mutation } from './Mutation';
-export { Query } from './Query';
-export { Subscription } from './Subscription';
-
-// Additional tools (advanced)
-export { Context, Consumer, Provider } from './context';
diff --git a/src/types.ts b/src/types.ts
index 22862c8b..47afc01e 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,7 +1,6 @@
 import { Source } from 'wonka';
-// import { ClientState } from './react';
-import { Client } from './lib/client';
-import { CombinedError } from './lib/error';
+import { Client } from './client';
+import { CombinedError } from './utils/error';
 
 /** The type of GraphQL operation being executed. */
 export type OperationType = 'subscription' | 'query' | 'mutation' | 'teardown';
diff --git a/src/lib/__snapshots__/hash.test.ts.snap b/src/utils/__snapshots__/hash.test.ts.snap
similarity index 100%
rename from src/lib/__snapshots__/hash.test.ts.snap
rename to src/utils/__snapshots__/hash.test.ts.snap
diff --git a/src/lib/error.test.ts b/src/utils/error.test.ts
similarity index 100%
rename from src/lib/error.test.ts
rename to src/utils/error.test.ts
diff --git a/src/lib/error.ts b/src/utils/error.ts
similarity index 100%
rename from src/lib/error.ts
rename to src/utils/error.ts
diff --git a/src/lib/hash.test.ts b/src/utils/hash.test.ts
similarity index 100%
rename from src/lib/hash.test.ts
rename to src/utils/hash.test.ts
diff --git a/src/lib/hash.ts b/src/utils/hash.ts
similarity index 100%
rename from src/lib/hash.ts
rename to src/utils/hash.ts
diff --git a/src/lib/index.ts b/src/utils/index.ts
similarity index 82%
rename from src/lib/index.ts
rename to src/utils/index.ts
index e2d610e5..17b2883b 100644
--- a/src/lib/index.ts
+++ b/src/utils/index.ts
@@ -1,4 +1,3 @@
-export { createClient, Client } from './client';
 export { CombinedError } from './error';
 export { hashString } from './hash';
 export { createQuery, createMutation, createSubscription } from './query';


Test patch:
diff --git a/src/lib/__snapshots__/client.test.ts.snap b/src/__snapshots__/client.test.ts.snap
similarity index 100%
rename from src/lib/__snapshots__/client.test.ts.snap
rename to src/__snapshots__/client.test.ts.snap
diff --git a/src/react/__snapshots__/context.test.ts.snap b/src/__snapshots__/context.test.ts.snap
similarity index 100%
rename from src/react/__snapshots__/context.test.ts.snap
rename to src/__snapshots__/context.test.ts.snap
diff --git a/src/lib/client.test.ts b/src/client.test.ts
similarity index 99%
rename from src/lib/client.test.ts
rename to src/client.test.ts
index 1ce159e8..eb92979f 100755
--- a/src/lib/client.test.ts
+++ b/src/client.test.ts
@@ -1,5 +1,5 @@
 /** NOTE: Testing in this file is designed to test both the client and it's interaction with default Exchanges */
-jest.mock('./hash', () => ({
+jest.mock('./utils/hash', () => ({
   hashString: () => 'hash',
 }));
 import { map, pipe, subscribe, tap } from 'wonka';
diff --git a/src/react/Mutation.test.tsx b/src/components/Mutation.test.tsx
similarity index 97%
rename from src/react/Mutation.test.tsx
rename to src/components/Mutation.test.tsx
index 51f522d0..c93839ef 100644
--- a/src/react/Mutation.test.tsx
+++ b/src/components/Mutation.test.tsx
@@ -1,4 +1,4 @@
-jest.mock('./context', () => {
+jest.mock('../context', () => {
   const c = {
     executeMutation: jest.fn(),
   };
@@ -13,7 +13,7 @@ import { mount } from 'enzyme';
 import React from 'react';
 import { fromValue } from 'wonka';
 // @ts-ignore - client is exclusively from mock
-import { client } from './context';
+import { client } from '../context';
 import { Mutation } from './Mutation';
 
 const props = {
diff --git a/src/react/Query.test.tsx b/src/components/Query.test.tsx
similarity index 97%
rename from src/react/Query.test.tsx
rename to src/components/Query.test.tsx
index b0cf7d80..7598e1de 100644
--- a/src/react/Query.test.tsx
+++ b/src/components/Query.test.tsx
@@ -1,4 +1,4 @@
-jest.mock('./context', () => {
+jest.mock('../context', () => {
   const c = {
     executeQuery: jest.fn(),
   };
@@ -13,7 +13,7 @@ import { mount, shallow } from 'enzyme';
 import React from 'react';
 import { delay, fromValue, pipe } from 'wonka';
 // @ts-ignore - client is exclusively from mock
-import { client } from './context';
+import { client } from '../context';
 import { Query } from './Query';
 
 const props = {
diff --git a/src/exchanges/cache.test.ts b/src/exchanges/cache.test.ts
index c272c1a3..563012d5 100755
--- a/src/exchanges/cache.test.ts
+++ b/src/exchanges/cache.test.ts
@@ -1,5 +1,5 @@
 import { makeSubject, map, pipe, publish, Source, Subject } from 'wonka';
-import { Client } from '../lib/client';
+import { Client } from '../client';
 import {
   mutationOperation,
   mutationResponse,
diff --git a/src/exchanges/dedup.test.ts b/src/exchanges/dedup.test.ts
index e9aab98b..440cd365 100644
--- a/src/exchanges/dedup.test.ts
+++ b/src/exchanges/dedup.test.ts
@@ -7,7 +7,7 @@ import {
   Source,
   Subject,
 } from 'wonka';
-import { Client } from '../lib/client';
+import { Client } from '../client';
 import {
   mutationOperation,
   queryOperation,
diff --git a/src/exchanges/fetch.test.ts b/src/exchanges/fetch.test.ts
index 95800965..8df7f860 100755
--- a/src/exchanges/fetch.test.ts
+++ b/src/exchanges/fetch.test.ts
@@ -1,5 +1,5 @@
 import { empty, fromValue, pipe, Source, subscribe, toPromise } from 'wonka';
-import { Client } from '../lib/client';
+import { Client } from '../client';
 import { queryOperation } from '../test-utils';
 import { OperationResult } from '../types';
 import { fetchExchange } from './fetch';
diff --git a/src/exchanges/subscription.test.ts b/src/exchanges/subscription.test.ts
index f3b88e69..f04dbff5 100644
--- a/src/exchanges/subscription.test.ts
+++ b/src/exchanges/subscription.test.ts
@@ -1,5 +1,5 @@
 import { empty, fromValue, pipe, Source, take, toPromise } from 'wonka';
-import { Client } from '../lib/client';
+import { Client } from '../client';
 import { subscriptionOperation, subscriptionResult } from '../test-utils';
 import { OperationResult } from '../types';
 import { subscriptionExchange, SubscriptionForwarder } from './subscription';
diff --git a/src/react/useMutation.test.tsx b/src/hooks/useMutation.test.tsx
similarity index 97%
rename from src/react/useMutation.test.tsx
rename to src/hooks/useMutation.test.tsx
index 49826f90..b5393914 100644
--- a/src/react/useMutation.test.tsx
+++ b/src/hooks/useMutation.test.tsx
@@ -1,5 +1,5 @@
 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
-jest.mock('../lib/client', () => {
+jest.mock('../client', () => {
   const d = { data: 1234, error: 5678 };
   const { delay, fromValue, pipe } = require('wonka');
   const mock = {
@@ -20,7 +20,7 @@ jest.mock('../lib/client', () => {
 import React, { FC } from 'react';
 import renderer, { act } from 'react-test-renderer';
 // @ts-ignore - data is imported from mock only
-import { createClient } from '../lib/client';
+import { createClient } from '../client';
 import { useMutation } from './useMutation';
 
 // @ts-ignore
diff --git a/src/react/useQuery.test.tsx b/src/hooks/useQuery.test.tsx
similarity index 98%
rename from src/react/useQuery.test.tsx
rename to src/hooks/useQuery.test.tsx
index 880baec9..fad0c86b 100644
--- a/src/react/useQuery.test.tsx
+++ b/src/hooks/useQuery.test.tsx
@@ -1,5 +1,5 @@
 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
-jest.mock('../lib/client', () => {
+jest.mock('../client', () => {
   const d = { data: 1234, error: 5678 };
   const { map, interval, pipe } = require('wonka');
   const mock = {
@@ -20,7 +20,7 @@ jest.mock('../lib/client', () => {
 import React, { FC } from 'react';
 import renderer, { act } from 'react-test-renderer';
 // @ts-ignore - data is imported from mock only
-import { createClient } from '../lib/client';
+import { createClient } from '../client';
 import { useQuery } from './useQuery';
 
 // @ts-ignore
diff --git a/src/react/useSubscription.test.tsx b/src/hooks/useSubscription.test.tsx
similarity index 96%
rename from src/react/useSubscription.test.tsx
rename to src/hooks/useSubscription.test.tsx
index a0f1d17c..c6e3a3df 100644
--- a/src/react/useSubscription.test.tsx
+++ b/src/hooks/useSubscription.test.tsx
@@ -1,5 +1,5 @@
 // Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
-jest.mock('../lib/client', () => {
+jest.mock('../client', () => {
   const d = { data: 1234, error: 5678 };
   const { fromArray } = require('wonka');
   const mock = {
@@ -15,7 +15,7 @@ jest.mock('../lib/client', () => {
 import React, { FC } from 'react';
 import renderer from 'react-test-renderer';
 // @ts-ignore - data is imported from mock only
-import { createClient, data } from '../lib/client';
+import { createClient, data } from '../client';
 import { useSubscription } from './useSubscription';
 
 // @ts-ignore