Skip to content

Commit

Permalink
Allow @dangerously_unaliased_fixme in updatable fragments
Browse files Browse the repository at this point in the history
Reviewed By: gordyf

Differential Revision: D69608990

fbshipit-source-id: 7c8383f4372834d4e9c05d949da5c431b1883bda
  • Loading branch information
captbaritone authored and facebook-github-bot committed Feb 13, 2025
1 parent de6da29 commit 3a16e22
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ use schema::Schema;
use super::ValidationMessage;
use super::ASSIGNABLE_DIRECTIVE;
use super::UPDATABLE_DIRECTIVE;
use crate::fragment_alias_directive::FRAGMENT_DANGEROUSLY_UNALIAS_DIRECTIVE_NAME;

lazy_static! {
static ref ALLOW_LISTED_DIRECTIVES: Vec<DirectiveName> = vec![
*UPDATABLE_DIRECTIVE,
*FRAGMENT_DANGEROUSLY_UNALIAS_DIRECTIVE_NAME,
// TODO have a global list of directives...?
DirectiveName("fb_owner".intern()),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
==================================== INPUT ====================================
query TestQuery @updatable {
node(id: 4) {
...FragmentOnUser @dangerously_unaliased_fixme
}
}

fragment FragmentOnUser on User @assignable {
__typename
}
==================================== OUTPUT ===================================
OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
query TestQuery @updatable {
node(id: 4) {
...FragmentOnUser @dangerously_unaliased_fixme
}
}

fragment FragmentOnUser on User @assignable {
__typename
}
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<<97d52b0fa84f80726d7eb06310a18c0d>>
* @generated SignedSource<<424418c51b45b6086d00947be17a05cd>>
*/

mod updatable_directive;
Expand Down Expand Up @@ -33,6 +33,13 @@ async fn client_side_updatable() {
test_fixture(transform_fixture, file!(), "client-side-updatable.graphql", "updatable_directive/fixtures/client-side-updatable.expected", input, expected).await;
}

#[tokio::test]
async fn dangerously_unaliased_allowed() {
let input = include_str!("updatable_directive/fixtures/dangerously-unaliased-allowed.graphql");
let expected = include_str!("updatable_directive/fixtures/dangerously-unaliased-allowed.expected");
test_fixture(transform_fixture, file!(), "dangerously-unaliased-allowed.graphql", "updatable_directive/fixtures/dangerously-unaliased-allowed.expected", input, expected).await;
}

#[tokio::test]
async fn directive_fragment_spread_invalid() {
let input = include_str!("updatable_directive/fixtures/directive-fragment-spread.invalid.graphql");
Expand Down

0 comments on commit 3a16e22

Please sign in to comment.