Skip to content

graphql allows types mismatch #853

@olegrok

Description

@olegrok

I have a type declaration:

kind_to_parse = {
    long = types.long.parseLiteral,
    float = types.float.parseLiteral,
    string = types.string.parseLiteral,
    boolean = types.boolean.parseLiteral,
}
types_any = types.scalar{
    name = 'Any',
    serialize = tostring, -- not used
    parseValue = tostring, -- not used
    parseLiteral = function(lit)
        if kind_to_parse[lit.kind] then
            return kind_to_parse[lit.kind](lit)
        end
        return nil
    end,
    isValueOfTheType = function(value)
        return type(value) ~= 'table'
    end
}

And I make a query - works OK:

query($login: Any, $is_active: Boolean) {
  Smth(first: 100, cid: [$login], is_active: $is_active) {
    myarg
  }
}

After changing "Any" to "String" query still works fine but GraphiQL shows an error:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggraphql

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions