Can you tell me what would be the best way to get a resource manually in custom component?
I'm using the simple GraphQL client for admin-on-rest.
aor-simple-graphql-client has been deprecated. Note that aor-graphql-client is meant to be used for admin-on-rest requests. If you need to send your own queries, you should use a custom ApolloClient and follow their documentation
Related
I'm new in this field. I'm very confused and need help.
How can I perform all GraphQL queries and mutations via Redux Toolkit?
(I should use the mutation only to get the token information while the user is logging in.)
While doing these, I need to use client.mutate / client.query instead of useQuery and useMutation, but I couldn't find any examples anywhere.
If you already use Apollo, you should not be using Redux Toolkit for api requests on to of that. Apollo is already a full-fledged api client & cache. You don't need to add a hand-written cache layer on top of that.
In this case you can still use Redux to manage non-api application state, but don't use it to do Apollo's job.
TLDR;
a middleware to nextjs like express where I only define it once and it'll automatically applies to all of my routes
I want a middleware style like we have in express I'll define a middleware inside the server.js(entry file) and the middleware will apply to all the routes without any other work needed. well I need similar thing to NextJs
these what I've been tried and used for a while
1: Using High Order Component (HOC):
I don't like this approach because of these drawbacks
Using HOC will disable fast-refresh functionality which's is really nice future to have More Info Here
I have to import my middleware in every api route file which is really not fun to do and wrapping your api files in a function is not a thing to remember all the time
2: using next-connect
I don't like to use this package due to these drawbacks
The nextjs ways to handle api routes seem more natural since i use nextjs i want to still use the nextjs way to handle my routes. not totally different style just for sake of a middleware
same as the HOC I don't like to import nc and my-middleware in every api file
well why not just using a custom server like express? the thing is when i use nextjs I want to only use nextjs also using a custom server will lose so many cool future of nextjs which's is partially why I use nextjs
You can implement _app.tsx, which will run for all pages, though it has some drawbacks too like disabling automatic static generation.
Another option is to implement a custom server using express itself, as shown in this example
I'm looking for the way to bind apollo to single components instead of wrapping the entire app, since we don't want to bind all our architecture to a service, now that we would use apollo only to retrieve data for a single component, and the way we retrieve that data could even change over time and maybe not use graphql anymore, or want to bind different graphql services to different components, so wrapping the entire app into an apollo provider is not our best choice.
Is there some way to avoid it?
Thanks
Wrapping entire app is needed to:
use shared, common cache as a single source of truth;
access from different places/app components.
You can wrap only one component if you wish.
You don't have to wrap any components to use graphql.
You can use "normal" fetch/axios requests to retrieve required data.
I have got a problem.
The scenario is we have two graphql servers.
I have split them passing context in the query/mutation options.
It works but I also have two different websocket setup.
As we can split subscription using hasSubscription(operation.query). It can be split only depending on query type.
But as I mentioned I have two websockets and I see there is no option to pass context in useSubscription like useQuery/useMutation.
Here is the documentation: https://www.apollographql.com/docs/react/data/subscriptions/#subscribetomore
There is no option to pass context in the subscription.
So what's the right way to achieve this?
Note: I'm using reactjs here.
try using useSubscription hook with client option. Thank you.
https://www.apollographql.com/docs/react/data/subscriptions/#useSubscription
I am doing a sample project with aws Appsync and ReactJs and my mutations are working fine. But I need a way to do the subscription part without using react-apollo. As far as I know Appsync is built based on apollo. So I believe there should be a way to do it purely with Appsync, by passing apollo.
I need some suggestions from expertise. Thanks in advance,
I tried with apoollo. But I need to do with minimum dependencies.
You can use the Amplify client https://aws-amplify.github.io/docs/js/api#amplify-graphql-client
I tried with apoollo. But I need to do with minimum dependencies.
You will always need a dependency since you will need a GraphQL client.
Here are some GraphQL clients that supports subscription aside from Apollo:
Relay
Amplify API
Since subscriptions are using web sockets under the hood, you can make use of Redux Saga's event channel.