Implementation of `startCursor` and` endCursor` in Relay

We have a graphql server not written in javascript, which we are trying to match the relay specification. startCursorand endCursorappear in a few examples, but not in official documents; based on my reading of https://github.com/facebook/relay/issues/372 , these fields are mostly out of date, but they still appear in some code. We must implement them:

  • to meet specifications?
  • to work with existing customers?
+4
source share
2 answers

, , . , , , Relay cursor , .

+2

?

, , .

?

, , Connection, Relay, Relay Modern . PaginationContainer, Relay Modern @connection:

[END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, START_CURSOR].forEach(
  fieldName => {
    const pageInfoField = pageInfoType.getFields()[fieldName];
    invariant(
      pageInfoField &&
        SchemaUtils.getNullableType(pageInfoField.type) instanceof
          GraphQLScalarType,
      'RelayConnectionTransform: Expected type `%s` to have an ' +
        '%s field for which the type is an scalar in document `%s`.',
      pageInfo.type,
      fieldName,
      definitionName,
    );
  }
);

, , endCursor startCursor . , graphql-relay-js :

startCursor: {
  type: GraphQLString,
  description: 'When paginating backwards, the cursor to continue.'
},
endCursor: {
  type: GraphQLString,
  description: 'When paginating forwards, the cursor to continue.'
},
0

Source: https://habr.com/ru/post/1625515/


All Articles