Feature request: createLocalInterface
See original GitHub issueWould it be beneficial to have a createLocalInterface
when you initially are trying out apollo-client / graphql in an existing stack?
The apollo-client and graphql can be a good alternative to all the redux boilerplating when it comes to maintaining a client cache/pagination/optimistic updates etc.
For now I basically just set up graphql schemas on the client and connected it directly to the ApolloClient
via a basic interface. The interface it not much code but it might not be the first thing newcommers would figure out.
The apollo client dev tools seem to be working out of the box with the client-side only interface. except it needs to be closed on hmr - it’s not reconnecting/reloading when in graphiql
I propose something like:
import { ApolloClient, createLocalInterface } from 'react-apollo';
import schema from './schema';
const localInterface = createLocalInterface(schema);
const client = new ApolloClient({
networkInterface: localInterface
});
networkInterface
doesn’t feel like the best name match for this case though
If needed I can do a pr with code and examples
Kind regards Morten
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
I think I’ll name it
createSchemaInterface
for now. I’ll have a pr ready tomorrowThe graphql schema resolveres could use rest endpoints or mock data.
It could be new users, or like in my case we dont have a graphql server yet - but I still want to leverage the Apollo client (I’m not keen on writing redux boilerplate code for defining a client cache for server data)