Skip to content

Commit

Permalink
Allow @required on connection fields
Browse files Browse the repository at this point in the history
Reviewed By: evanyeung

Differential Revision: D64977566

fbshipit-source-id: 65a61976b0e1c2775a31c07b4b2a11c08d5ba8f1
  • Loading branch information
captbaritone authored and facebook-github-bot committed Oct 29, 2024
1 parent 20db11e commit d079b29
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
==================================== INPUT ====================================
# expected-to-throw
query connectionFieldRequiredQuery($first: Int, $last: Int) {
node(id: "4") {
comments(first: $first, last: $last) @connection(key: "Hello_comments") {
Expand All @@ -12,18 +11,378 @@ query connectionFieldRequiredQuery($first: Int, $last: Int) {
}
}
}
==================================== ERROR ====================================
✖︎ @required fields must be included in all instances of their parent. The field 'id` is marked as @required here

connection-field-required.graphql:8:11
7 │ node {
8 │ id @required(action: THROW)
│ ^^
9 │ }
==================================== OUTPUT ===================================
{
"fragment": {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
}
],
"kind": "Fragment",
"metadata": null,
"name": "connectionFieldRequiredQuery",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "id",
"value": "4"
}
],
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": "comments",
"args": null,
"concreteType": "CommentsConnection",
"kind": "LinkedField",
"name": "__Hello_comments_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "count",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "CommentsEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Comment",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"kind": "RequiredField",
"field": {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
"action": "THROW",
"path": "node.comments.edges.node.id"
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": "node(id:\"4\")"
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "first"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
}
],
"kind": "Operation",
"name": "connectionFieldRequiredQuery",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "id",
"value": "4"
}
],
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "first",
"variableName": "first"
},
{
"kind": "Variable",
"name": "last",
"variableName": "last"
}
],
"concreteType": "CommentsConnection",
"kind": "LinkedField",
"name": "comments",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "count",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "CommentsEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "Comment",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "first",
"variableName": "first"
},
{
"kind": "Variable",
"name": "last",
"variableName": "last"
}
],
"filters": null,
"handle": "connection",
"key": "Hello_comments",
"kind": "LinkedHandle",
"name": "comments"
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
}
],
"storageKey": "node(id:\"4\")"
}
]
},
"params": {
"cacheID": "14c7e32a8f3e3856e6990dc692487ea5",
"id": null,
"metadata": {
"connection": [
{
"count": null,
"cursor": null,
"direction": "bidirectional",
"path": [
"node",
"comments"
]
}
]
},
"name": "connectionFieldRequiredQuery",
"operationKind": "query",
"text": null
}
}

ℹ︎ but is missing from
QUERY:

<generated>:1:1
1 │ # expected-to-throw
│ ^
2 │ query connectionFieldRequiredQuery($first: Int, $last: Int) {
query connectionFieldRequiredQuery(
$first: Int
$last: Int
) {
node(id: "4") {
__typename
comments(first: $first, last: $last) {
count
edges {
node {
id
__typename
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
id
}
}
Loading

0 comments on commit d079b29

Please sign in to comment.