Skip to content

Allow String to be used as the cursor type #1028

@myronmarston

Description

@myronmarston

The relay pagination spec says:

An “Edge Type” must contain a field called cursor. This field must return a type that serializes as a String; this may be a String, a Non-Null wrapper around a String, a custom scalar that serializes as a String, or a Non-Null wrapper around a custom scalar that serializes as a String.

Whatever type this field returns will be referred to as the cursor type in the rest of this spec.

ElasticGraph provides a Cursor type for use here. However, the spec allows other types to be used for the cursor. In an organization that used a custom scalar cursor type that was called something else, you can use type_name_overrides in your Rakefile to solve this:

  tasks.type_name_overrides = {
    Cursor: "RelayCursor"
  }

It's also valid for the cursor type to be String. But this doesn't work:

  tasks.type_name_overrides = {
    Cursor: "String"
  }

There are two problems here:

  • This causes ElasticGraph to generate scalar String in the GraphQL schema...which conflicts with the existing definition of String.
  • ElasticGraph has a scalar coercion adapter for Cursor which should not apply to String. (That is, it's logic is still needed for cursor values passed as a String, but not for other String values).

We'll need to find a solution for both of these. Maybe the cursor logic can be moved out of the scalar coercion adapter and applied to individual cursor values rather than to the Cursor type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions