Posts

Showing posts from November, 2018

GraphQL Express: Queries on child items.

Full disclosure this blog is me learning in public. Maybe this is obvious to you, maybe there is a better way to do this, if so let me know. In the end it caught me out so I thought I'd write down what my solution ended up being. The problem: In the GraphQL documentation the servers are always shown returning simple hello world style results. I wanted to be able to find all the items associated with a user ID and then all items that match certain criteria within that set. The project that I have been using to learn GraphQL is an implementation of the Tech Radar idea that was popularised by ThoughtWorks . In this the client can select a radar and potentially a subset of the items on the radar, say they only want to display a single section. In the GraphQL Express examples it shows how to grab top level items, filtering these is easy. You can grab all the data from your data source and pass it through a filter function and return it. Simple. It looks something like this: 1 2 ...