Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local state management #334

Open
knownasilya opened this issue Jan 3, 2020 · 4 comments
Open

Local state management #334

knownasilya opened this issue Jan 3, 2020 · 4 comments

Comments

@knownasilya
Copy link
Contributor

How does one add local resolvers for local state management like here: https://www.apollographql.com/docs/react/data/local-state/

@xomaczar
Copy link

@knownasilya did you find a way to have local cache resolvers?

@knownasilya
Copy link
Contributor Author

No

@adrienbaudhuin
Copy link

@knownasilya You need to override clientOptions() in ApolloService to add local resolvers :

export default class OverriddenApolloService extends ApolloService {
  clientOptions() {
    return {
      link: this.link(),
      cache: this.cache(),
      resolvers: {
        MyType: {
          myData: (parent, args, obj) => {
            return "data";
          }
        }
      },
      typeDefs: types // If you need to extend somethings
    };
  }
}

Then, you need to set the service when you create a queryManager:

export default Route.extend({
  apollo: queryManager({ service: "overriddenApolloService" }),
  
  // your route
}); 

@knownasilya
Copy link
Contributor Author

Does MyType already have to exist in the schema? Or can that be a new type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants