-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
babel-relay-plugin: disallow before/first after/last; inline actual e…
…rrors Summary: Makes the use of `field(before: .., first: ..)` or after/last an error. This combination is only supported when generated by Relay during the diffing process. Also, the previous version replaced invalid GraphQL templates with a function that throws - while I was at it, I changed this to include the actual validation error message. Addresses #247 Closes #252 Reviewed By: @yuzhi Differential Revision: D2419715
- Loading branch information
1 parent
a2336ba
commit f679656
Showing
10 changed files
with
206 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
scripts/babel-relay-plugin/src/__fixtures__/connectionWithAfterLastCalls.fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Input: | ||
var Relay = require('react-relay'); | ||
var x = Relay.QL` | ||
query { | ||
node(id: 123) { | ||
friends(last: 3, after: "foo") { | ||
edges { | ||
node { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
Output: | ||
var Relay = require('react-relay'); | ||
var x = (function () { | ||
throw new Error('GraphQL validation/transform error ``Connections arguments `friends(after: <cursor>, last: <count>)` are not supported. Use `(last: <count>)` or `(before: <cursor>, last: <count>)`. `` in file `connectionWithAfterLastCalls.fixture`.'); | ||
})(); |
21 changes: 21 additions & 0 deletions
21
scripts/babel-relay-plugin/src/__fixtures__/connectionWithBeforeFirstCalls.fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Input: | ||
var Relay = require('react-relay'); | ||
var x = Relay.QL` | ||
query { | ||
node(id: 123) { | ||
friends(first: 3, before: "foo") { | ||
edges { | ||
node { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
Output: | ||
var Relay = require('react-relay'); | ||
var x = (function () { | ||
throw new Error('GraphQL validation/transform error ``Connections arguments `friends(before: <cursor>, first: <count>)` are not supported. Use `(first: <count>)` or `(after: <cursor>, first: <count>)`. `` in file `connectionWithBeforeFirstCalls.fixture`.'); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters