Created
          May 27, 2024 13:48 
        
      - 
      
- 
        Save rmosolgo/79fc159fa2ef0ce94f37874ab292e953 to your computer and use it in GitHub Desktop. 
    Optional list investigation
  
        
  
    
      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
    
  
  
    
  | require "bundler/inline" | |
| gemfile do | |
| gem "racc" | |
| # gem "graphql", "2.0.16" | |
| gem "graphql", "2.2.3" | |
| end | |
| class MySchema < GraphQL::Schema | |
| class Query < GraphQL::Schema::Object | |
| field :echo, String do | |
| argument :input, [String], required: false | |
| end | |
| def echo(input: :ruby_default_value) | |
| "#{GraphQL::VERSION}: " + input.inspect | |
| end | |
| end | |
| query(Query) | |
| end | |
| pp MySchema.execute("{ echo }").to_h | |
| pp MySchema.execute("{ echo(input: null) }").to_h | |
| pp MySchema.execute("{ echo(input: []) }").to_h | |
| pp MySchema.execute("{ echo(input: [\"hello\"]) }").to_h | |
| # {"data"=>{"echo"=>"2.0.16: :ruby_default_value"}} | |
| # {"data"=>{"echo"=>"2.0.16: nil"}} | |
| # {"data"=>{"echo"=>"2.0.16: []"}} | |
| # {"data"=>{"echo"=>"2.0.16: [\"hello\"]"}} | |
| # {"data"=>{"echo"=>"2.2.3: :ruby_default_value"}} | |
| # {"data"=>{"echo"=>"2.2.3: nil"}} | |
| # {"data"=>{"echo"=>"2.2.3: []"}} | |
| # {"data"=>{"echo"=>"2.2.3: [\"hello\"]"}} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment