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

babel-relay-plugin: generalize warning about nodes fields #185

Conversation

josephsavona
Copy link
Contributor

GraphQL servers may support various forms of pagination, for example:

type UserConnection {
  edges: [UserEdge] # a) access the relationship between the parent record and the User
  users: [User] # b) directly access the linked Users. 
}
type UserEdge {
  node: User
}

Relay currently supports only a) - the edges{node{...}} variant, and warns about case b) only if the field is called nodes. This PR changes the warning by detecting any use of the b) pattern regardless of the field's name.

cc @dschafer @leebyron @schrockn @yuzhi

@josephsavona josephsavona force-pushed the babel-plugin-generalize-nodes-warning branch from 949edb3 to e41cac7 Compare August 28, 2015 02:25
'Unsupported "nodes" field on connection, `%s`. Instead, use ' +
'"edges{node{...}}".',
'Unsupported `%s{...}` field on connection `%s`. Use ' +
'`edges{node{...}}` instead.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth expanding on this warning to explain why this is unsupported?

'`%s{...}` field on connection `%s` does not allow cursor insertion. ' +
'Use `edges{node{...}}` instead to allow Relay to auto-insert ' +
'`edges{cursor}` for efficient pagination',

josephsavona added a commit that referenced this pull request Aug 28, 2015
…es-warning

babel-relay-plugin: generalize warning about `nodes` fields
@josephsavona josephsavona merged commit ecc163a into facebook:master Aug 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants