-
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.
Add test asserting __token is added when flag is enabled
- Loading branch information
1 parent
de151c6
commit 8633085
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
...fetchable_fragment/fixtures/fragment-on-non-node-fetchable-type-with-token-field.expected
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,59 @@ | ||
==================================== INPUT ==================================== | ||
# // enable-token-field: true | ||
|
||
fragment RefetchableFragment on NonNodeStory | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
actor { | ||
...ProfilePicture | ||
} | ||
} | ||
|
||
fragment ProfilePicture on User { | ||
profilePicture(size: $size) { | ||
uri | ||
} | ||
} | ||
==================================== OUTPUT =================================== | ||
query RefetchableFragmentQuery( | ||
$size: [Int] | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragment", | ||
# ), | ||
# ) | ||
{ | ||
fetch__NonNodeStory(input_fetch_id: $id) { | ||
...RefetchableFragment | ||
} | ||
} | ||
|
||
fragment ProfilePicture on User { | ||
profilePicture(size: $size) { | ||
uri | ||
} | ||
} | ||
|
||
fragment RefetchableFragment on NonNodeStory @refetchable(queryName: "RefetchableFragmentQuery") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: OperationDefinitionName( | ||
# "RefetchableFragmentQuery", | ||
# ), | ||
# path: [ | ||
# "fetch__NonNodeStory", | ||
# ], | ||
# identifier_info: Some( | ||
# RefetchableIdentifierInfo { | ||
# identifier_field: "fetch_id", | ||
# identifier_query_variable_name: "id", | ||
# }, | ||
# ), | ||
# } | ||
{ | ||
actor { | ||
...ProfilePicture | ||
} | ||
fetch_id | ||
__token | ||
} |
14 changes: 14 additions & 0 deletions
14
...efetchable_fragment/fixtures/fragment-on-non-node-fetchable-type-with-token-field.graphql
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,14 @@ | ||
# // enable-token-field: true | ||
|
||
fragment RefetchableFragment on NonNodeStory | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
actor { | ||
...ProfilePicture | ||
} | ||
} | ||
|
||
fragment ProfilePicture on User { | ||
profilePicture(size: $size) { | ||
uri | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
compiler/crates/relay-transforms/tests/refetchable_fragment/mod.rs
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,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
use fixture_tests::Fixture; | ||
use graphql_test_helpers::apply_transform_for_test; | ||
use relay_transforms::transform_connections; | ||
use relay_transforms::transform_refetchable_fragment; | ||
use relay_transforms::ConnectionInterface; | ||
|
||
pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> { | ||
apply_transform_for_test(fixture, |program| { | ||
let program = transform_connections(program, &ConnectionInterface::default()); | ||
let base_fragments = Default::default(); | ||
let schema_config = if fixture.content.contains("// enable-token-field: true") { | ||
let mut schema_config: relay_config::SchemaConfig = Default::default(); | ||
schema_config.enable_token_field = true; | ||
schema_config | ||
} else { | ||
Default::default() | ||
}; | ||
transform_refetchable_fragment(&program, &schema_config, &base_fragments, false) | ||
}) | ||
} |
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