DEV Community

Discussion on: Using GraphQL with Dojo

Collapse
 
wanzulfikri profile image
wanzulfikri • Edited

This is my first time hearing about Dojo. I’m mainly a React dude but it is always interesting to read about the different ways of building for the web.

I used Apollo with React but I don’t think I’ve used any factory methods. What do they do?

Collapse
 
odoenet profile image
Rene Rubalcava

Because I'm keeping this Appolo wrapper fairly generic, if I were to use multiple queries in my application, I would want the result of each one to update a different state.

In my Query wrapper, I am creating a single state

export const Query = StoreContainer(BaseQuery, "state", {
  getProperties
});

But if I different parts of my application have their own queries and results, I think I would need to get the Query wrapper via a factory method that might do something like this.

export function queryFactory(stateName: string) {
  return const Query = StoreContainer(BaseQuery, stateName {
    getProperties
  });
}

I haven't tried this method yet, but it should make sure that each query doesn't override the state that another part of my application might be using.

If this is a multi-page routable application, I don't think it's much of a concern.

Glad you liked the post! Dojo is doing some very interesting stuff, in particular in their build pipeline that I think is really exciting!

Collapse
 
wanzulfikri profile image
wanzulfikri

Thank you for the explanation. Keep up the good work.