Created
          August 21, 2016 20:01 
        
      - 
      
 - 
        
Save taion/2d6d5c9c07029a08117a2e7ee188797e to your computer and use it in GitHub Desktop.  
    GraphQL CRUD partial updates
  
        
  
    
      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
    
  
  
    
  | /* @flow */ | |
| import { GraphQLNonNull } from 'graphql'; | |
| export default function makeRequired(partial?: boolean) { | |
| if (partial) { | |
| return (type: mixed) => type; | |
| } | |
| return (type: mixed) => new GraphQLNonNull(type); | |
| } | 
  
    
      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
    
  
  
    
  | /* @flow */ | |
| import { GraphQLString } from 'graphql'; | |
| import makeRequired from './makeRequired'; | |
| export default function widgetFields(partial?: boolean) { | |
| const required = makeRequired(partial); | |
| return { | |
| name: { type: required(GraphQLString) }, | |
| description: { type: GraphQLString }, | |
| color: { type: required(GraphQLString) }, | |
| }; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment