brysgo / graphql-gun

A graphql API for the gun p2p graph database
405 stars 20 forks source link

Documentation: How to filter a set? #20

Open sebastianmacias opened 6 years ago

sebastianmacias commented 6 years ago

I'm looking at the example:


const myQuery = gql`{
  fish {
    red {
      name
    }

    blue {
      _chain
    }

    friends(type: Set) {
      name
      favoriteColor
    }
  }
}`;

it there a way to return only the friends whose favoriteColor is gold instead the of the full set?

brysgo commented 6 years ago

Hey Sebastian, hope you are enjoying playing around with this. Since there is no filter query in gundb (that I know of) the only way I could think to do this is in JavaScript.

I would be happy to entertain any suggestions, be it custom query params or a built in filter parameter.

sebastianmacias commented 6 years ago

Thanks for your reply @brysgo.

Maybe a package like lodash-query or array-query could be integrated to make graphql-gun even more helpful. I am willing to contribute once I'm a little bit more experienced with gun.js. I just started using gun.js on some small projects a few months ago but I'm definitely often needing to further filter my query sets in javascript. I think it would save me a lot of time if it was part of this library.

brysgo commented 6 years ago

Great, excited to hear some ideas once you get there!

ansarizafar commented 6 years ago

It is a must has feature. Is there any update on this issue?

brysgo commented 6 years ago

This shouldn't be that difficult to tackle for anyone who is interested. Especially if it is must has :-D