Skip to content

Commit

Permalink
Add tests with custom node query variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilios1995 committed Mar 6, 2023
1 parent 70ef1a5 commit 9f3f74d
Show file tree
Hide file tree
Showing 5 changed files with 1,118 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
==================================== INPUT ====================================
fragment fragmentOnNodeInterface_RefetchableFragment on Node
@refetchable(queryName: "RefetchableFragmentQuery") {
global_id
... on User {
name
...fragmentOnNodeInterface_ProfilePicture
}
}

fragment fragmentOnNodeInterface_ProfilePicture on User {
profilePicture(size: $size) {
uri
}
}
==================================== OUTPUT ===================================
{
"fragment": {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "global_id"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "size"
}
],
"kind": "Fragment",
"metadata": null,
"name": "RefetchableFragmentQuery",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "global_id",
"variableName": "global_id"
}
],
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "fragmentOnNodeInterface_RefetchableFragment"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "size"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "global_id"
}
],
"kind": "Operation",
"name": "RefetchableFragmentQuery",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "global_id",
"variableName": "global_id"
}
],
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
{
"kind": "TypeDiscriminator",
"abstractKey": "__isNode"
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "global_id",
"storageKey": null
},
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "size",
"variableName": "size"
}
],
"concreteType": "Image",
"kind": "LinkedField",
"name": "profilePicture",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "uri",
"storageKey": null
}
],
"storageKey": null
}
],
"type": "User",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "31dcd57f42128b8d975e6224202a17c9",
"id": null,
"metadata": {},
"name": "RefetchableFragmentQuery",
"operationKind": "query",
"text": null
}
}

QUERY:

query RefetchableFragmentQuery(
$size: [Int]
$global_id: ID!
) {
node(global_id: $global_id) {
__typename
...fragmentOnNodeInterface_RefetchableFragment
global_id
}
}

fragment fragmentOnNodeInterface_ProfilePicture on User {
profilePicture(size: $size) {
uri
}
}

fragment fragmentOnNodeInterface_RefetchableFragment on Node {
__isNode: __typename
global_id
... on User {
name
...fragmentOnNodeInterface_ProfilePicture
}
}


{
"argumentDefinitions": [
{
"kind": "RootArgument",
"name": "size"
}
],
"kind": "Fragment",
"metadata": null,
"name": "fragmentOnNodeInterface_ProfilePicture",
"selections": [
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "size",
"variableName": "size"
}
],
"concreteType": "Image",
"kind": "LinkedField",
"name": "profilePicture",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "uri",
"storageKey": null
}
],
"storageKey": null
}
],
"type": "User",
"abstractKey": null
}

{
"argumentDefinitions": [
{
"kind": "RootArgument",
"name": "size"
}
],
"kind": "Fragment",
"metadata": {
"refetch": {
"connection": null,
"fragmentPathInResult": [
"node"
],
"operation": require('RefetchableFragmentQuery.graphql'),
"identifierField": "global_id",
"identifierQueryVariableName": "variable_name"
}
},
"name": "fragmentOnNodeInterface_RefetchableFragment",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "global_id",
"storageKey": null
},
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"args": null,
"kind": "FragmentSpread",
"name": "fragmentOnNodeInterface_ProfilePicture"
}
],
"type": "User",
"abstractKey": null
}
],
"type": "Node",
"abstractKey": "__isNode"
}
Loading

0 comments on commit 9f3f74d

Please sign in to comment.