Skip to content

Is the count operation for limiting queries necessary? #174

Closed
@ahokinson

Description

@ahokinson

My understanding is that pagination and limiting should be enabled by using the SQLAlchemyConnectionField on a Connection type.

Running a query such as,

{
  facts(first: 1) {
    edges {
      node {
        id
        appid
        pageid
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}

yields a SQL query without LIMIT %s, %s in the SELECT statement which is suggested to be the case in #27. Specifically, the generated query is,

SELECT count(*) AS count_1 
FROM (SELECT "TABLE".id AS "TABLE_id", "TABLE".appid AS "TABLE_appid", "TABLE".pageid AS "TABLE_pageid" 
FROM "TABLE" ORDER BY "TABLE".id ASC) AS anon_1

My schema is pretty straight forward,

from graphene import Connection, ObjectType, Schema, relay
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType

from models.generated.fact import Fact as FactModel


class Fact(SQLAlchemyObjectType):
    class Meta:
        model = FactModel
        interfaces = (relay.Node,)


class FactConnection(Connection):
    class Meta:
        node = Fact


class Query(ObjectType):
    node = relay.Node.Field()
    facts = SQLAlchemyConnectionField(FactConnection)


schema = Schema(query=Query)

and my model (while generated) is,

class Fact(Base):
    __tablename__ = "TABLE"
    id = Column(Integer, primary_key=True)
    appid = Column(Integer)
    pageid = Column(String)

Am I missing a step or is this possibly a bug? I am using graphene-sqlalchemy 2.1.0.

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