Skip to content

Commit 7c836df

Browse files
tyao1facebook-github-bot
authored andcommittedOct 6, 2020
Fix prependNode and prependEdge in declarative connection
Reviewed By: kassens Differential Revision: D24125989 fbshipit-source-id: 37ad78a55c37225197b898b25c2b93cc49df4dd2
1 parent f417138 commit 7c836df

File tree

4 files changed

+198
-3
lines changed

4 files changed

+198
-3
lines changed
 

‎compiler/crates/graphql-transforms/src/declarative_connection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ lazy_static! {
4040
pub static ref CONNECTIONS_ARG_NAME: StringKey = "connections".intern();
4141
pub static ref DELETE_RECORD: StringKey = "deleteRecord".intern();
4242
pub static ref DELETE_EDGE: StringKey = "deleteEdge".intern();
43-
pub static ref PREPEND_EDGE: StringKey = "prependNode".intern();
44-
pub static ref PREPEND_NODE: StringKey = "prependEdge".intern();
43+
pub static ref PREPEND_EDGE: StringKey = "prependEdge".intern();
44+
pub static ref PREPEND_NODE: StringKey = "prependNode".intern();
4545
pub static ref EDGE_TYPENAME_ARG: StringKey = "edgeTypeName".intern();
4646
}
4747

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
==================================== INPUT ====================================
2+
mutation prependNodeCommentCreateMutation(
3+
$connections: [String!]!
4+
$edgeTypeName: String!
5+
$input: CommentCreateInput
6+
) {
7+
commentCreate(input: $input) {
8+
comment
9+
@prependNode(connections: $connections, edgeTypeName: $edgeTypeName) {
10+
id
11+
}
12+
}
13+
}
14+
==================================== OUTPUT ===================================
15+
{
16+
"fragment": {
17+
"argumentDefinitions": [
18+
{
19+
"defaultValue": null,
20+
"kind": "LocalArgument",
21+
"name": "connections"
22+
},
23+
{
24+
"defaultValue": null,
25+
"kind": "LocalArgument",
26+
"name": "edgeTypeName"
27+
},
28+
{
29+
"defaultValue": null,
30+
"kind": "LocalArgument",
31+
"name": "input"
32+
}
33+
],
34+
"kind": "Fragment",
35+
"metadata": null,
36+
"name": "prependNodeCommentCreateMutation",
37+
"selections": [
38+
{
39+
"alias": null,
40+
"args": [
41+
{
42+
"kind": "Variable",
43+
"name": "input",
44+
"variableName": "input"
45+
}
46+
],
47+
"concreteType": "CommentCreateResponsePayload",
48+
"kind": "LinkedField",
49+
"name": "commentCreate",
50+
"plural": false,
51+
"selections": [
52+
{
53+
"alias": null,
54+
"args": null,
55+
"concreteType": "Comment",
56+
"kind": "LinkedField",
57+
"name": "comment",
58+
"plural": false,
59+
"selections": [
60+
{
61+
"alias": null,
62+
"args": null,
63+
"kind": "ScalarField",
64+
"name": "id",
65+
"storageKey": null
66+
}
67+
],
68+
"storageKey": null
69+
}
70+
],
71+
"storageKey": null
72+
}
73+
],
74+
"type": "Mutation",
75+
"abstractKey": null
76+
},
77+
"kind": "Request",
78+
"operation": {
79+
"argumentDefinitions": [
80+
{
81+
"defaultValue": null,
82+
"kind": "LocalArgument",
83+
"name": "connections"
84+
},
85+
{
86+
"defaultValue": null,
87+
"kind": "LocalArgument",
88+
"name": "edgeTypeName"
89+
},
90+
{
91+
"defaultValue": null,
92+
"kind": "LocalArgument",
93+
"name": "input"
94+
}
95+
],
96+
"kind": "Operation",
97+
"name": "prependNodeCommentCreateMutation",
98+
"selections": [
99+
{
100+
"alias": null,
101+
"args": [
102+
{
103+
"kind": "Variable",
104+
"name": "input",
105+
"variableName": "input"
106+
}
107+
],
108+
"concreteType": "CommentCreateResponsePayload",
109+
"kind": "LinkedField",
110+
"name": "commentCreate",
111+
"plural": false,
112+
"selections": [
113+
{
114+
"alias": null,
115+
"args": null,
116+
"concreteType": "Comment",
117+
"kind": "LinkedField",
118+
"name": "comment",
119+
"plural": false,
120+
"selections": [
121+
{
122+
"alias": null,
123+
"args": null,
124+
"kind": "ScalarField",
125+
"name": "id",
126+
"storageKey": null
127+
}
128+
],
129+
"storageKey": null
130+
},
131+
{
132+
"alias": null,
133+
"args": null,
134+
"filters": null,
135+
"handle": "prependNode",
136+
"key": "",
137+
"kind": "LinkedHandle",
138+
"name": "comment",
139+
"handleArgs": [
140+
{
141+
"kind": "Variable",
142+
"name": "connections",
143+
"variableName": "connections"
144+
},
145+
{
146+
"kind": "Variable",
147+
"name": "edgeTypeName",
148+
"variableName": "edgeTypeName"
149+
}
150+
]
151+
}
152+
],
153+
"storageKey": null
154+
}
155+
]
156+
},
157+
"params": {
158+
"id": null,
159+
"metadata": {},
160+
"name": "prependNodeCommentCreateMutation",
161+
"operationKind": "mutation",
162+
"text": null
163+
}
164+
}
165+
166+
QUERY:
167+
168+
mutation prependNodeCommentCreateMutation(
169+
$input: CommentCreateInput
170+
) {
171+
commentCreate(input: $input) {
172+
comment {
173+
id
174+
}
175+
}
176+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mutation prependNodeCommentCreateMutation(
2+
$connections: [String!]!
3+
$edgeTypeName: String!
4+
$input: CommentCreateInput
5+
) {
6+
commentCreate(input: $input) {
7+
comment
8+
@prependNode(connections: $connections, edgeTypeName: $edgeTypeName) {
9+
id
10+
}
11+
}
12+
}

‎compiler/crates/relay-compiler/tests/compile_relay_artifacts_test.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @generated SignedSource<<deea4fe8b36fd52433a73728036fe08d>>
1+
// @generated SignedSource<<55b6e275266a28edb1038b45ff766344>>
22

33
mod compile_relay_artifacts;
44

@@ -586,6 +586,13 @@ fn plural_fragment() {
586586
test_fixture(transform_fixture, "plural-fragment.graphql", "compile_relay_artifacts/fixtures/plural-fragment.expected", input, expected);
587587
}
588588

589+
#[test]
590+
fn prepend_node() {
591+
let input = include_str!("compile_relay_artifacts/fixtures/prepend-node.graphql");
592+
let expected = include_str!("compile_relay_artifacts/fixtures/prepend-node.expected");
593+
test_fixture(transform_fixture, "prepend-node.graphql", "compile_relay_artifacts/fixtures/prepend-node.expected", input, expected);
594+
}
595+
589596
#[test]
590597
fn query_with_conditional_module() {
591598
let input = include_str!("compile_relay_artifacts/fixtures/query-with-conditional-module.graphql");

0 commit comments

Comments
 (0)
Please sign in to comment.