Skip to content

Error is raised when first or last argument is negative #210

@marijnvanwezel

Description

@marijnvanwezel

When the first or last argument of a connection field is negative, an error is raised. This only seems to happen when first or last is -2 or lower (surprisingly not when it is -1).

Steps to reproduce

Execute a query where the first or last argument of a connection field is -2 or lower.

Expected result

The query is not executed, and a proper error is returned.

Actual result

A Postgrex error is raised:

# Postgrex.Error at POST /graphiql

Exception:

    ** (Postgrex.Error) ERROR 2201W (invalid_row_count_in_limit_clause) LIMIT must not be negative
        (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1096: Ecto.Adapters.SQL.raise_sql_call_error/1
        (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:994: Ecto.Adapters.SQL.execute/6
        (ecto 3.12.5) lib/ecto/repo/queryable.ex:232: Ecto.Repo.Queryable.execute/4
        (ecto 3.12.5) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
        (absinthe_relay 1.5.2) lib/absinthe/relay/connection.ex:462: Absinthe.Relay.Connection.from_query/4
        (absinthe 1.7.8) lib/absinthe/resolution.ex:206: Absinthe.Resolution.call/2
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:234: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:189: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:174: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:145: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:284: Absinthe.Phase.Document.Execution.Resolution.build_result/3
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:174: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:145: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:67: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
        (absinthe 1.7.8) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
        (absinthe 1.7.8) lib/absinthe/pipeline.ex:408: Absinthe.Pipeline.run_phase/3
        (absinthe_plug 1.5.8) lib/absinthe/plug.ex:536: Absinthe.Plug.run_query/4
        (absinthe_plug 1.5.8) lib/absinthe/plug.ex:290: Absinthe.Plug.call/2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions