I have this input object that I wanted to have an optional array with a default value, but I get this error:
@[GraphQL::InputObject]
class GoalInput
include GraphQL::InputObjectType
getter title : String
getter milestones : Array(String)
@[GraphQL::Field]
def initialize(
@title : String,
@milestones : Array(String) = [] of String,
)
end
end
There was a problem expanding macro 'values'
Code in lib/graphql/src/graphql/language/nodes.cr:149:7
149 | values({name: String, type: Type, default_value: FValue, directives: Array(Directive), description: String?})
^
Called macro defined in lib/graphql/src/graphql/language/ast.cr:4:7
4 | macro values(args)
Which expanded to:
> 8 | @name = name
> 9 | @type = type
> 10 | @default_value = default_value
^------------
Error: instance variable '@default_value' of GraphQL::Language::InputValueDefinition must be GraphQL::Language::FValue, not Array(String)
Removing the default value off the array no longer produces the error.
I have this input object that I wanted to have an optional array with a default value, but I get this error:
Removing the default value off the array no longer produces the error.