Created
July 7, 2019 12:09
-
-
Save nataliemarleny/19ce507479779bf0d4f9aa184bf00f80 to your computer and use it in GitHub Desktop.
ES6 object syntax (implicit object properties)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reduced | |
const obj1 = { | |
fun1() {} | |
} | |
const obj1 = { | |
fun1: () => {} | |
} | |
// this | |
// source: https://www.apollographql.com/docs/graphql-tools/resolvers/#unions-and-interfaces | |
const resolverMap = { | |
Vehicle: { | |
__resolveType(obj, context, info) { | |
if (obj.wingspan) { | |
return 'Airplane'; | |
} | |
if (obj.licensePlate) { | |
return 'Car'; | |
} | |
return null; | |
} | |
} | |
}; | |
// is the same as (source: brain + time) | |
const resolverMap = { | |
Vehicle: { | |
__resolveType: (obj, context, info) => { | |
if (obj.wingspan) { | |
return 'Airplane'; | |
} | |
if (obj.licensePlate) { | |
return 'Car'; | |
} | |
return null; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment