datacite / lupo

DataCite REST API
https://api.datacite.org
MIT License
11 stars 8 forks source link

GraphQL paging over related people for an organisation generates erro #732

Open richardhallett opened 3 years ago

richardhallett commented 3 years ago

When attempting to query related people and retrieve a cursor for pagination the query fails.

Example below

{
  organization(id: "https://ror.org/04qmmjx98") {
    id
    name
    country {
      name
    }

    people {
      edges {
        cursor
        node {
          id
        }
      }
    }
  }
}
mfenner commented 3 years ago

Please see https://www.pidforum.org/t/pagination-with-cursor-in-graphql-api/1572

richardhallett commented 3 years ago

Okay so in which case, the specific structure of this query causes an error, it generates a 500 on our side https://sentry.io/share/issue/51fdb3ca15f243b5843427f01df64f4d/

I think the user is handled then by your response in PID Forum but there is still an underlying issue here with the generated 500, unless im missing something the above query should be valid.

mfenner commented 3 years ago

The correct way to do this is to obtain the (end-)cursor from a pageInfo object:

pageInfo {
        endCursor
        hasNextPage
      }

And then use the cursor with the after property.

people(after: "MQ")
richardhallett commented 3 years ago

This is specific to our graphql API? the docs generated on our API however suggest that its reasonable to return a cursor on edges that can then later be used i.e. like you said "after: "MQ"

See

image

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jrhoads commented 2 years ago

Digging into this it looks like any connection should implement cursor_for_node Which would be used for the edge cursor

https://graphql-ruby.org/api-doc/1.8.5/GraphQL/Relay/BaseConnection.html

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jrhoads commented 1 year ago

Still relevant