-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completes full graphql query support
# Why * The mocking is not working correctly. * Tests are failing. * Typings are off. # What * Adds a new `mockApollo` Provider that is a complete stand-in replacement for `ApolloProvider` and `client`. It more or less creates a mock networkInterface for Apollo, then uses a schema generated from an introspection query against the JSON schema generated from the server in order to provide Apollo with an executable schema it can auto-mock against types (or use custom mocks passed in). It also has support for passing in initial state, else it defers to the state derived from the reducers. * Fixes bug with test execution - `apolli-client` has an optional dependency specified for react-dom 16.x. Removing it from `yarn.lock` and reinstalling the packages solved the problem. [Open Issue](apollographql/react-apollo#826) * Fixes mock queries for `viewer`. * Adds better type support for Graphql. Part of this includes removing the `withData` higher order component for the time being until we can figure out how to deal with some of the more complex type errors it was producing. A complete example of the way to wrap a component with a query can be found in `routes/docs/examples/grapqhl/root.tsx` with a corresponding test in the same location. * Adds a `mockGraphql` function for returning a mocked query outside of a test - like if you want to mock some data out without making changes to the server. * Schema generation and type generation from the schema / used queries is now fully automated. It triggers with `yarn run start` (Dev) and `yarn run build` (Prod). This prevents the client from ever getting out of sync with the server and enforces strict type checking on every query, subscription, or mutation.
- Loading branch information
Gabe Weaver
committed
Jul 14, 2017
1 parent
de5ea37
commit ba76f2b
Showing
34 changed files
with
18,950 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module '*.gql' { | ||
const value: any | ||
export = value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import client from './client' | ||
import mutate, { Mutations, MutationTypes } from './mutations' | ||
import query, { Queries, QueryTypes } from './queries' | ||
import mutate, { Mutations } from './mutations' | ||
import query, { Queries } from './queries' | ||
|
||
export { | ||
mutate, | ||
Mutations, | ||
MutationTypes, | ||
query, | ||
Queries, | ||
QueryTypes | ||
Queries | ||
} | ||
|
||
export default client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ addMockFunctionsToSchema({ | |
schema: mockSchema | ||
}) | ||
|
||
export { mocks } | ||
export default mockSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import getAllPagesMocks from './getAllPages' | ||
import viewer from './viewer' | ||
|
||
export default { | ||
...getAllPagesMocks | ||
Query: () => ({ | ||
...viewer | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { buildClientSchema } from 'graphql' | ||
import * as introspectionResult from '../schema.json' | ||
import * as introspectionResult from '../scaphold.schema.json' | ||
|
||
export const schema = buildClientSchema(introspectionResult.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.