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

Managing Local State #54

Closed
idkjs opened this issue Sep 22, 2020 · 3 comments
Closed

Managing Local State #54

idkjs opened this issue Sep 22, 2020 · 3 comments

Comments

@idkjs
Copy link
Contributor

idkjs commented Sep 22, 2020

What would be the equivalent in this project of this code:

const IS_LOGGED_IN = gql`
  query IsUserLoggedIn { 
   isLoggedIn @client 
 }`

It found in the apollo docs here-> https://www.apollographql.com/docs/tutorial/local-state/.

I guess this is a query on the client which we would set up with cache?

@jeddeloh
Copy link
Owner

Yes, assuming you've done the work of making it available in the cache you would use it just like normal:

[%graphql {|
  query IsUserLoggedIn { 
    isLoggedIn @client 
  }
|}]

The complication here is that you now need to account for this in your graphql_schema.json that graphql-ppx is consuming. We have some client state in our apps and I think I used some combination of graphql-tools and graphql-codegen to combine the schemas, but I don't know what would be best today. If you're just playing around, you could probably specify a separate schema for your client-only queries?

@idkjs
Copy link
Contributor Author

idkjs commented Sep 24, 2020

oh wow. got an error before when i tried using @client. Seperate schema....I can see conceptually how we would do that. I am going to try that. Be nice to have an example of some of these less used cases in the repo or docs so if I get it done, I will share it if you want it. Thanks for the feedback, sir.

@idkjs idkjs closed this as completed Sep 24, 2020
@jfrolich
Copy link
Collaborator

Hmm yes this would be interesting to implement within graphql-ppx. However, I don't know if many people use this feature. I certainly don't use it and I don't really see direct benefits of using this instead of simple client state with useState.

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

No branches or pull requests

3 participants