Why is a connection query resulting in this SQL qu...
# orm-help
l
Why is a connection query resulting in this SQL query?
Copy code
query usersConnection {
  usersConnection(first: 2, after: "a") {
    edges {
      node {
        id
        name
      }
      cursor
    }
  }
}
Copy code
2019-05-14 16:07:19.230 UTC [778] LOG:  execute <unnamed>: select 
	  "Alias"."id", 
	  "Alias"."name"
	from "local$dev"."User" as "Alias"
	where (
	  (
	    "Alias"."id" = (
	      select "local$dev"."User"."id"
	      from "local$dev"."User"
	      where "local$dev"."User"."id" = $1
	    )
	    and "Alias"."id" > $2
	  )
	  or "Alias"."id" > (
	    select "local$dev"."User"."id"
	    from "local$dev"."User"
	    where "local$dev"."User"."id" = $3
	  )
	)
	order by "Alias"."id" asc
	limit $4
	offset $5
2019-05-14 16:07:19.230 UTC [778] DETAIL:  parameters: $1 = 'a', $2 = 'a', $3 = 'a', $4 = '3', $5 = '0'
h
cc @marcus or @do4gr
l
Already solved it in my next comment: it's because of order by. If you specify a different sort order, like name_desc, it uses the extra query to be able to query from the ID correctly instead of using a separate cursor (the cursor is the ID). cc @bkstorm
👍 1
h
👍