facebook / facebook/relay

Rely compiler throws error when pageInfo does not have hasPreviousPage key

Open
#3,242 5 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to do only forward pagination. Here's my SDL (I've skipped irrelevant parts of the schema):
```graphql
type Group implements Node {
id: ID!
emailInvitations(
first: NonNegativeInt
after: String
filter: EmailInvitationsFilter
): EmailInvitationConnection
}

type EmailInvitationConnection {
edges: [EmailInvitationEdge!]
pageInfo: EmailInvitationConnectionPageInfo!
totalCount: NonNegativeInt
}
type EmailInvitationConnectionPageInfo {
hasNextPage: Boolean!
endCursor: String!
}
```
And I'm using usePagination with the following fragment
```graphql
fragment Invitations_group on Group
@refetchable(queryName: "EmailInvitationsPaginationQuery")
@argumentDefinitions(
count: { type: "NonNegativeInt!", defaultValue: 5 }
cursor: { type: "String", defaultValue: null }
status: { type: "EmailInvitationStatus", defaultValue: null }
email: { type: "StringFilter", defaultValue: null }
) {
emailInvitations(
first: $count
after: $cursor
filter: { status: $status, email: $email }
) @connection(key: "Invitations_group_emailInvitations") {
edges {
node {
...Invitations_row
id
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
```
When using relay compiler for typescript, it's throws the error:
```
ERROR:
Internal Error: Unknown field 'hasPreviousPage' on type 'EmailInvitationConnectionPageInfo'.
```
My question is if I only want to do forward pagination, why does relay compiler enforce hasPreviousPage field as required on pageInfo?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.