Last active
May 5, 2017 02:11
-
-
Save github0013/2bd68d7569d49533ab629ca05f3f8238 to your computer and use it in GitHub Desktop.
apollo doesn't return values nor error when [Episode]! type has null value
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
module Types | |
Level1Type = GraphQL::ObjectType.define do | |
name "Level1Type" | |
field :name, types.String | |
end | |
ArrayWithNullValueType = GraphQL::ObjectType.define do | |
name "ArrayWithNullValueType" | |
field :level1s, !types[Level1Type] | |
end | |
end |
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
module Types | |
QueryType = GraphQL::ObjectType.define do | |
name "Query" | |
field :ArrayWithNullValue do | |
type !ArrayWithNullValueType | |
resolve ->(obj, args, ctx) { | |
level1s = [ | |
nil, | |
OpenStruct.new(name: "some name1"), | |
OpenStruct.new(name: "some name2") | |
] | |
OpenStruct.new(level1s: level1s) | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment