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
{ | |
"0": [ | |
-16.38360023498535, | |
-58.31719970703125 | |
], | |
"UTK": [ | |
11.222, | |
169.852005 | |
], | |
"OCA": [ |
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 is a script that looks for usage of a specific field in GraphQL | |
// queries in your codebase. | |
// | |
// First, add a .graphqlconfig in your directory pointing to your schema | |
// Then, run the script with: | |
// | |
// node graphql-field-finder.js Field.name | |
// | |
// It will output a list of files and queries that contain the field you're | |
// looking for: |
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
storiesOf('TodoList', module) | |
.add('renders a list', () => { | |
const customResolvers = { | |
Todo: () => ({ | |
text: 'My todo item text', | |
}), | |
}; | |
return ( | |
<ApolloMockingProvider customResolvers={customResolvers}> |
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
it('renders a list', async () => { | |
const customResolvers = { | |
Todo: () => ({ | |
text: 'My todo item', | |
}), | |
}; | |
const wrapper = mount( | |
<ApolloMockingProvider customResolvers={customResolvers}> | |
<TodoList /> |
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
export const ErrorProvider = (props) => { | |
// This is just a link that swallows all operations and returns the same thing | |
// for every request: The specified error. | |
const link = new ApolloLink((operation) => { | |
return new Observable((observer) => { | |
observer.next({ | |
errors: props.graphQLErrors || [ | |
{message: 'Unspecified error from ErrorProvider.'}, | |
], | |
}); |
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
const LoadingProvider = (props) => { | |
const link = new ApolloLink((operation) => { | |
return new Observable(() => {}); | |
}); | |
const client = new ApolloClient({ | |
link, | |
cache: new InMemoryCache(), | |
}); | |
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
const ApolloMockingProvider = (props) => { | |
const mocks = mergeResolvers(globalMocks, props.customResolvers); | |
addMockFunctionsToSchema({ schema, mocks }); | |
const client = new ApolloClient({ | |
link: new SchemaLink({ schema }), | |
cache: new InMemoryCache(), | |
}); | |
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
import TodoList from './TodoList'; | |
// Specify some resolvers for this instance | |
const customResolvers = { | |
Query: () => ({ | |
todoItems: [ | |
{ completed: true }, | |
{ completed: false }, | |
] | |
}) |
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
import faker from 'faker'; | |
const mocks = { | |
Todo: () => ({ | |
text: () => faker.sentence(), | |
completed: () => faker.random.boolean(), | |
}), | |
User: () => ({ | |
name: () => faker.name.findName() | |
}) |
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
import { ApolloClient } from 'apollo-client'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import { SchemaLink } from 'apollo-link-schema'; | |
// Import the schema object from previous code snippet above | |
import schema from './path/to/your/schema'; | |
const client = new ApolloClient({ | |
cache: new InMemoryCache(), | |
link: new SchemaLink({ schema }) |
NewerOlder