Apollo GraphQL
Hello
How can I use Apollo in Wasp?
normally I'd do like this but in wasp I am not sure where to put it.
15 Replies
Wohooo @nicode_it, you just became a Waspeteer level 1!
Hi @nicode_it. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In Wasp, you can set up Apollo in the root component of your application. This is done in the
client
field inside the app
declaration in your main.wasp
file. Here's how you can do it:
Then, in your Root.jsx
file, you can set up Apollo like this:
In this setup, children
represents the actual pages of your application. As long as you render the children, you can do whatever you want in your root component.
For more information, you can read about the root component in the API Reference (https://wasp-lang.dev/docs/project/client-config#rootcomponent-extimport) and about setting up a provider in the Wasp documentation (https://wasp-lang.dev/docs/project/client-config#setting-up-a-provider).
Please note that the code snippets provided are based on the knowledge sources provided and may need to be adjusted to fit your specific use case.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @nicode_it, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?I don't think this solution is correct, I will try.
You should be able to use it as in any JS project, but you would have to manually plug it in and use it -> it is not something that Wasp supports out of the box as one of its integral parts.
thanks
Do you think the way explained by the kapa.ai is good?
I tried it quickly and it did not work but maybe I should try again.
General direction sounds right to me -> that said, I haven't used Apollo much so I can't speak about the details. Maybe if you can explain more about the situation: what didn't work exactly, what do you think should work, which parts you are sure about and which you are not, ... . As I said, I don't know much about Apollo, so I can help with Wasp, but you will have to know the stuff from the Apollo side.
Thanks. Off topic but how do I set the auth to go to a specific page instead of / after login?
Overview | Wasp
Auth is an essential piece of any serious application. That's why Wasp provides authentication and authorization support out of the box.
Thanks mate. Could not find it smh
It's a bit low-key in the docs yeah we should make it more prominent
I am enjoying wasp so far. Might start contributing if I can.
Right now building a small gamified app related to github contributions.
Will share when public.
Awesome, that is really nice to hear :)! We are here for any help, and any feedback is always very welcome, so we can improve things based on it. Certainly share it in #🏠made-with-wasp , we have quite some cool stuff being built there!
BTW this method works, I had some typos..
Awesome! Do you think Wasp could have helped more? Maybe better error messaging or something like that?
Honestly I don't remember now 😄