Created
          May 1, 2017 19:51 
        
      - 
      
- 
        Save timhudson/c2e6a0cce7fb5b358ba4f88d6919badf to your computer and use it in GitHub Desktop. 
    Colocating GraphQL resolvers with types
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | export default ` | |
| type RootQuery { | |
| user(id = String, email = String) User | |
| } | |
| ` | |
| export const user = async (_, { id, email }, ctx) => { | |
| return { | |
| id: 'this', | |
| name: 'that' | |
| } | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | export default ` | |
| type User { | |
| id: String! | |
| created: String | |
| isAdmin: Boolean | |
| name: String | |
| lastSeen: String | |
| email: String | |
| } | |
| ` | |
| export const isAdmin = async ({ id }, _, ctx) => ctx.checkAdmin(id) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment