GraphQL - first steps

I was following Flavio Copes' tutorial on creating a basic GraphQL server in Express the other day. The tutorial was good, but I realised at the end that it didn't give you an example of a query to actually see the resolvers in action.

Luckily I've picked up enough GraphQL to be able to write a simple query; just need to get the subscriptions sorted now!

The query below will return title and author name for all posts; then title and author for only post 0.

{
  posts {
    title
    author {
      name
    }
  },
  post(id: 0) {
    title
    author {
      name
    }
  }
}

Subscribe to Paul Walker

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe