Last active
March 17, 2019 23:52
-
-
Save kandros/4528fa21d589f443620a1c1834616872 to your computer and use it in GitHub Desktop.
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
# somewhere in schema definition | |
type User { | |
name: String! | |
lastname: String! | |
fullname: String! | |
} | |
// somewhere in server code | |
const resolvers = { | |
Query: { | |
getUsers() { | |
return users | |
} | |
}, | |
User: { | |
fullname: { | |
/** | |
* without this you are force to set in the query name and lastname everytime you request | |
* fullname, or it will not receive the value here and get undefined insted | |
*/ | |
fragment: `... on User { name, lastname }`, | |
resolve: (parent, args, context, info ) { | |
return parent.name + return parent.lastname | |
} | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment