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

Chain module #92

Open
shiftlabs1 opened this issue Jul 10, 2022 · 7 comments
Open

Chain module #92

shiftlabs1 opened this issue Jul 10, 2022 · 7 comments

Comments

@shiftlabs1
Copy link

I noticed the chain feature was not carried over from genql. any reason for that ? alongside the dependency upgrade/introduction and axios, it would be nice to keep the chain syntax

@meabed
Copy link
Owner

meabed commented Jul 10, 2022

I noticed the chain feature was not carried over from genql. any reason for that ? alongside the dependency upgrade/introduction and axios, it would be nice to keep the chain syntax

Thank you for the comment.

Yes, I removed because I exposed axios config as 3rd param in the request and in chain mode it will conflict with multiple chaining, so it need to be reworked a bit, so I removed it in a short term but definitely will added it agin soon

@shiftlabs1
Copy link
Author

earnestly looking forward to this (chain implementation). for my nuxt3 project, I would use a custom fetcher (oh-my-fetch), as it is inbuilt an isomorphic

@shiftlabs1
Copy link
Author

@meabed
What happens if you have this for client definition

 const client: {
    wsClient?: WSClient;
    query?: Function;
    mutation?: Function;
    subscription?: Function;
    fetcherInstance: BaseFetcher["fetcherInstance"];
    fetcherMethod: BaseFetcher["fetcherMethod"];
    chain?: {
      query?: Function
      mutation?: Function
      subscription?: Function
  }
  } = {
    fetcherInstance,
    fetcherMethod,
  };

and include config as a 4th parameter for chain methods like

 client.chain = {
    query: chain((path, request, defaultValue,config) =>
        client.query(request,config).then(mapResponse(path, defaultValue)),
    ),
    mutation: chain((path, request, defaultValue,config) =>
        client.mutation(request,config).then(mapResponse(path, defaultValue)),
    ),
    subscription: chain((path, request, defaultValue,config) => {
        const obs = client.subscription(request,config)
        const mapper = mapResponse(path, defaultValue)
        return Observable.from(obs).map(mapper)
    }),
}

@shiftlabs1 shiftlabs1 reopened this Sep 7, 2022
@shiftlabs1
Copy link
Author

@meabed I didn't get any response on this. Is this now included ?

@meabed
Copy link
Owner

meabed commented Sep 8, 2022

Thanks @shiftlabs1 would you share an idea how do you want to use this feature?

@shiftlabs1
Copy link
Author

@meabed , its same way it's used in genql. its a genql feature that was omitted in your fork , no ?

@meabed
Copy link
Owner

meabed commented Sep 8, 2022

Yes, I removed it as was conflicting with sending custom headers or axios config while chaining

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

2 participants