flow /**
 * This defines a basic set of data for our Star Wars Schema.
 *
 * This data is hard coded for the sake of the demo, but you could imagine
 * fetching this data from a backend service rather than from hardcoded
 * JSON objects in a more complex demo.
 */ const luke = { type : "Human" , id : "1000" , name : "Luke Skywalker" , friends : [ "1002" , "1003" , "2000" , "2001" ] , appearsIn : [ 4 , 5 , 6 ] , homePlanet : "Tatooine" } ; const vader = { type : "Human" , id : "1001" , name : "Darth Vader" , friends : [ "1004" ] , appearsIn : [ 4 , 5 , 6 ] , homePlanet : "Tatooine" } ; const han = { type : "Human" , id : "1002" , name : "Han Solo" , friends : [ "1000" , "1003" , "2001" ] , appearsIn : [ 4 , 5 , 6 ] } ; const leia = { type : "Human" , id : "1003" , name : "Leia Organa" , friends : [ "1000" , "1002" , "2000" , "2001" ] , appearsIn : [ 4 , 5 , 6 ] , homePlanet : "Alderaan" } ; const tarkin = { type : "Human" , id : "1004" , name : "Wilhuff Tarkin" , friends : [ "1001" ] , appearsIn : [ 4 ] } ; const humanData = { "1000" : luke , "1001" : vader , "1002" : han , "1003" : leia , "1004" : tarkin } ; const threepio = { type : "Droid" , id : "2000" , name : "C-3PO" , friends : [ "1000" , "1002" , "1003" , "2001" ] , appearsIn : [ 4 , 5 , 6 ] , primaryFunction : "Protocol" } ; const artoo = { type : "Droid" , id : "2001" , name : "R2-D2" , friends : [ "1000" , "1002" , "1003" ] , appearsIn : [ 4 , 5 , 6 ] , primaryFunction : "Astromech" } ; const droidData = { "2000" : threepio , "2001" : artoo } ; function getCharacter ( id ) { return Promise . resolve ( humanData [ id ] || droidData [ id ] ) ; } export function getFriends ( character ) { return character . friends . map ( id => getCharacter ( id ) ) ; } export function getHero ( episode ) { if ( episode === 5 ) { return luke ; } return artoo ; } export function getHuman ( id ) { return humanData [ id ] ; } export function getDroid ( id ) { return droidData [ id ] ; }