Skip to content

Auto-generate Connection, PageInfo, and Edge schema type definitions #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #103
rstoyanchev opened this issue Feb 22, 2023 · 0 comments
Closed
Tracked by #103
Assignees
Labels
in: core Issues related to config and core support type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

The Relay connection spec requires adding boilerplate Connection and Edge types for each domain type that requires pagination.

When Relay pagination is enabled, after schema files are parsed, we will check for fields whose type name ends on "Connection", which the spec defines this as a reserved type. If no type definition is not present for that type name, we will create it.

For example, given the following declarations in schema.graphqls:

type Query {
	books: BookConnection
}
type Book {
	id: ID!
	title: String!
}

The following additional type definitions would be added transparently on startup:

type BookConnection {
	edges: [BookEdge]!
	pageInfo: PageInfo!
}

type BookEdge {
	cursor: String!
	node: Book!
}

type PageInfo {
	hasPreviousPage: Boolean!
	hasNextPage: Boolean!
	startCursor: String
	endCursor: String
}
@rstoyanchev rstoyanchev added type: enhancement A general enhancement in: core Issues related to config and core support labels Feb 22, 2023
@rstoyanchev rstoyanchev added this to the 1.2.0-M1 milestone Feb 22, 2023
@rstoyanchev rstoyanchev self-assigned this Feb 22, 2023
@rstoyanchev rstoyanchev changed the title Support generation of Relay Connection and Edge Types Auto-generation of Relay Connection and Edge Type Definitions Feb 22, 2023
@rstoyanchev rstoyanchev changed the title Auto-generation of Relay Connection and Edge Type Definitions Auto-generate Connection, PageInfo, and Edge schema type definitions Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues related to config and core support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant