Skip to content

Instantly share code, notes, and snippets.

@petehunt
Last active November 8, 2018 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petehunt/8739f2758c723bf8f4d1dcccbf64c0c4 to your computer and use it in GitHub Desktop.
Save petehunt/8739f2758c723bf8f4d1dcccbf64c0c4 to your computer and use it in GitHub Desktop.

graphql

hero {
  name
  friends {
    name
  }
}

sql

select
  (select name from people as p where p.id = h.id) as name,
  array(select
    (select name from people as p2 where p2.id = hf.friend_id) as name
    from hero_friends as hf
    where hf.hero_id = h.id
  ) as friends
from heroes as h;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment