Skip to content
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

[relay-compiler] Compiler doesn't work for connections when types are non-nullable #1835

Open
nikolasburk opened this issue May 30, 2017 · 4 comments

Comments

@nikolasburk
Copy link
Contributor

I'm having an issue with the relay-compiler that fails when fields are required.

Here's a simplified version of the schema that I used when I was hitting the issue.

allPosts(after: String, before: String, first: Int, last: Int): PostConnection!

type PostConnection {
  pageInfo: PageInfo!
  edges: [PostEdge]
}

type PostEdge {
  node: Post!
  cursor: String!
}

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

type Post {
  id: ID!
  title: String!
}

Using required fields on the connections caused the compiler to fail with the following error:

Invariant Violation: RelaySchemaUtils: Expected type `PostConnection!` to be an object or interface type.

image

Using the following schema without required fields works:

allPosts(after: String, before: String, first: Int, last: Int): PostConnection

type PostConnection {
  pageInfo: PageInfo
  edges: [PostEdge]
}

type PostEdge {
  node: Post
  cursor: String
}

type PageInfo {
  hasNextPage: Boolean
  hasPreviousPage: Boolean
  startCursor: String
  endCursor: String
}

type Post {
  id: ID!
  title: String!
}

Feel free to take a look at the full project (note that the README doesn't yet include instructions about setting up the relay-compiler).

@kassens
Copy link
Member

kassens commented May 31, 2017

If you want to take a look, the cause is most likely in RelayConnectionTransform.validateConnectionType.

Adding a new connection to the test schema that's non-nullable to extend the test in RelayConnectionTransform-test.js would be great!

@kassens kassens added the bug label May 31, 2017
@nikolasburk
Copy link
Contributor Author

Hey Jan, thanks for thee hint! This seems like a slightly bigger refactor since assertTypeWithFields is used in multiple places, I'm not really comfortable doing that right now. I'll be releasing a getting started tutorial about Relay Modern today where I adjust the schema and remove the constraint for certain fields to be required in order to work around the issue.

@nikolasburk
Copy link
Contributor Author

FYI - the tutorial is now online: https://www.graph.cool/docs/tutorials/relay-modern-getting-started-woodito7ug

@nikolasburk nikolasburk changed the title [Modern] Compiler doesn't work for @connection directive when types are non-nullable [Modern] Compiler doesn't work for connections when types are non-nullable Jul 1, 2017
@nikolasburk nikolasburk changed the title [Modern] Compiler doesn't work for connections when types are non-nullable [relay-compiler] Compiler doesn't work for connections when types are non-nullable Jul 1, 2017
@stale
Copy link

stale bot commented Dec 25, 2020

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.

@stale stale bot added the wontfix label Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants