Skip to content

Commit

Permalink
Demonstrate client edges getting swallowed
Browse files Browse the repository at this point in the history
Reviewed By: alunyov

Differential Revision: D37112971

fbshipit-source-id: 7dde52800458ba5f23e2af4c68d5035cf32aa17a
  • Loading branch information
captbaritone authored and facebook-github-bot committed Jun 14, 2022
1 parent ec1bed6 commit b193cad
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
==================================== INPUT ====================================
fragment multipleClientEdges_best_friend_resolver on User {
actor_key
}

fragment multipleClientEdges_worst_enemy_resolver on User {
actor_key
}

query multipleClientEdgesQuery {
me {
best_friend {
name
}
worst_enemy {
name
}
}
}

# %extensions%

type ClientUser {
name: String
}

extend type User {
best_friend: ClientUser
@relay_resolver(
fragment_name: "multipleClientEdges_best_friend_resolver"
import_path: "./foo/bar/baz/BestFriendResolver.js"
)
}

extend type User {
worst_enemy: ClientUser
@relay_resolver(
fragment_name: "multipleClientEdges_worst_enemy_resolver"
import_path: "./foo/bar/baz/WorstEnemyResolver.js"
)
}
==================================== OUTPUT ===================================
{
"fragment": {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": {
"hasClientEdges": true
},
"name": "multipleClientEdgesQuery",
"selections": [
{
"alias": null,
"args": null,
"concreteType": "User",
"kind": "LinkedField",
"name": "me",
"plural": false,
"selections": [
{
"kind": "ClientEdgeToClientObject",
"concreteType": "ClientUser",
"backingField": {
"alias": null,
"args": null,
"fragment": {
"args": null,
"kind": "FragmentSpread",
"name": "multipleClientEdges_best_friend_resolver"
},
"kind": "RelayResolver",
"name": "best_friend",
"resolverModule": require('BestFriendResolver'),
"path": "me.best_friend"
},
"linkedField": {
"alias": null,
"args": null,
"concreteType": "ClientUser",
"kind": "LinkedField",
"name": "best_friend",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
}
],
"storageKey": null
}
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [],
"kind": "Operation",
"name": "multipleClientEdgesQuery",
"selections": [
{
"alias": null,
"args": null,
"concreteType": "User",
"kind": "LinkedField",
"name": "me",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "actor_key",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "f025e3b1fa71b0e5fb8b91b7240b401d",
"id": null,
"metadata": {},
"name": "multipleClientEdgesQuery",
"operationKind": "query",
"text": null
}
}

QUERY:

query multipleClientEdgesQuery {
me {
...multipleClientEdges_best_friend_resolver
...multipleClientEdges_worst_enemy_resolver
id
}
}

fragment multipleClientEdges_best_friend_resolver on User {
actor_key
}

fragment multipleClientEdges_worst_enemy_resolver on User {
actor_key
}


{
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "multipleClientEdges_best_friend_resolver",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "actor_key",
"storageKey": null
}
],
"type": "User",
"abstractKey": null
}

{
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "multipleClientEdges_worst_enemy_resolver",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "actor_key",
"storageKey": null
}
],
"type": "User",
"abstractKey": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
fragment multipleClientEdges_best_friend_resolver on User {
actor_key
}

fragment multipleClientEdges_worst_enemy_resolver on User {
actor_key
}

query multipleClientEdgesQuery {
me {
best_friend {
name
}
worst_enemy {
name
}
}
}

# %extensions%

type ClientUser {
name: String
}

extend type User {
best_friend: ClientUser
@relay_resolver(
fragment_name: "multipleClientEdges_best_friend_resolver"
import_path: "./foo/bar/baz/BestFriendResolver.js"
)
}

extend type User {
worst_enemy: ClientUser
@relay_resolver(
fragment_name: "multipleClientEdges_worst_enemy_resolver"
import_path: "./foo/bar/baz/WorstEnemyResolver.js"
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b624096206b1ae7f449954aa43055967>>
* @generated SignedSource<<bb104b68ef6fd27fe501fb72fd99293f>>
*/

mod compile_relay_artifacts;
Expand Down Expand Up @@ -656,6 +656,13 @@ fn module_with_defer() {
test_fixture(transform_fixture, "module-with-defer.graphql", "compile_relay_artifacts/fixtures/module-with-defer.expected", input, expected);
}

#[test]
fn multiple_client_edges() {
let input = include_str!("compile_relay_artifacts/fixtures/multiple-client-edges.graphql");
let expected = include_str!("compile_relay_artifacts/fixtures/multiple-client-edges.expected");
test_fixture(transform_fixture, "multiple-client-edges.graphql", "compile_relay_artifacts/fixtures/multiple-client-edges.expected", input, expected);
}

#[test]
fn multiple_conditions() {
let input = include_str!("compile_relay_artifacts/fixtures/multiple_conditions.graphql");
Expand Down

0 comments on commit b193cad

Please sign in to comment.