-
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 support for refetchable interfaces
Summary: In https://fb.workplace.com/groups/relay.support/permalink/10086229424758915/, it was revealed that fetchable interfaces are not currently supported by relay, even though they could be. * Add support for (re) fetchable interfaces Reviewed By: davidmccabe Differential Revision: D41747533 fbshipit-source-id: 1cf1ae88645c9b9dcbff7e97a2060232a9a6550d
- Loading branch information
1 parent
ee4874a
commit d00df58
Showing
12 changed files
with
388 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
47 changes: 47 additions & 0 deletions
47
...tchable_fragment/fixtures/refetchable-interface-all-implementing-types-impl-node.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,47 @@ | ||
==================================== INPUT ==================================== | ||
fragment RefetchableFragment on RefetchableInterface | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
interface RefetchableInterface @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterface(id: ID!): RefetchableInterface | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface implements RefetchableInterface & Node { | ||
id: ID! | ||
} | ||
==================================== OUTPUT =================================== | ||
query RefetchableFragmentQuery( | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragment", | ||
# ), | ||
# ) | ||
{ | ||
node(id: $id) { | ||
...RefetchableFragment | ||
} | ||
} | ||
|
||
fragment RefetchableFragment on RefetchableInterface @refetchable(queryName: "RefetchableFragmentQuery") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: "RefetchableFragmentQuery", | ||
# path: [ | ||
# "node", | ||
# ], | ||
# identifier_field: Some( | ||
# "id", | ||
# ), | ||
# } | ||
{ | ||
id | ||
} |
18 changes: 18 additions & 0 deletions
18
...etchable_fragment/fixtures/refetchable-interface-all-implementing-types-impl-node.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,18 @@ | ||
fragment RefetchableFragment on RefetchableInterface | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
interface RefetchableInterface @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterface(id: ID!): RefetchableInterface | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface implements RefetchableInterface & Node { | ||
id: ID! | ||
} |
46 changes: 46 additions & 0 deletions
46
...ts/refetchable_fragment/fixtures/refetchable-interface-but-no-implementing-types.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,46 @@ | ||
==================================== INPUT ==================================== | ||
# Because there are no implementing types, "all implementing types impl Node" | ||
# is true, so we generated a Node refetch query. | ||
fragment RefetchableFragmentFoo on RefetchableInterfaceFoo | ||
@refetchable(queryName: "RefetchableFragmentFooQuery") { | ||
id | ||
} | ||
|
||
|
||
# %extensions% | ||
|
||
interface RefetchableInterfaceFoo @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterfaceFoo(id: ID!): RefetchableInterfaceFoo | ||
} | ||
==================================== OUTPUT =================================== | ||
query RefetchableFragmentFooQuery( | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragmentFoo", | ||
# ), | ||
# ) | ||
{ | ||
node(id: $id) { | ||
...RefetchableFragmentFoo | ||
} | ||
} | ||
|
||
fragment RefetchableFragmentFoo on RefetchableInterfaceFoo @refetchable(queryName: "RefetchableFragmentFooQuery") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: "RefetchableFragmentFooQuery", | ||
# path: [ | ||
# "node", | ||
# ], | ||
# identifier_field: Some( | ||
# "id", | ||
# ), | ||
# } | ||
{ | ||
id | ||
} |
17 changes: 17 additions & 0 deletions
17
...sts/refetchable_fragment/fixtures/refetchable-interface-but-no-implementing-types.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,17 @@ | ||
# Because there are no implementing types, "all implementing types impl Node" | ||
# is true, so we generated a Node refetch query. | ||
fragment RefetchableFragmentFoo on RefetchableInterfaceFoo | ||
@refetchable(queryName: "RefetchableFragmentFooQuery") { | ||
id | ||
} | ||
|
||
|
||
# %extensions% | ||
|
||
interface RefetchableInterfaceFoo @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterfaceFoo(id: ID!): RefetchableInterfaceFoo | ||
} |
52 changes: 52 additions & 0 deletions
52
...s/tests/refetchable_fragment/fixtures/refetchable-interface-some-types-impl-node.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,52 @@ | ||
==================================== INPUT ==================================== | ||
fragment RefetchableFragment on RefetchableInterface | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
interface RefetchableInterface @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterface(id: ID!): RefetchableInterface | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface implements RefetchableInterface & Node { | ||
id: ID! | ||
} | ||
|
||
type ConcreteType2ImplementingRefetchableInterface implements RefetchableInterface { | ||
id: ID! | ||
} | ||
==================================== OUTPUT =================================== | ||
query RefetchableFragmentQuery( | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragment", | ||
# ), | ||
# ) | ||
{ | ||
fetch__RefetchableInterface(id: $id) { | ||
...RefetchableFragment | ||
} | ||
} | ||
|
||
fragment RefetchableFragment on RefetchableInterface @refetchable(queryName: "RefetchableFragmentQuery") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: "RefetchableFragmentQuery", | ||
# path: [ | ||
# "fetch__RefetchableInterface", | ||
# ], | ||
# identifier_field: Some( | ||
# "id", | ||
# ), | ||
# } | ||
{ | ||
id | ||
__token | ||
} |
23 changes: 23 additions & 0 deletions
23
...ms/tests/refetchable_fragment/fixtures/refetchable-interface-some-types-impl-node.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,23 @@ | ||
fragment RefetchableFragment on RefetchableInterface | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
interface RefetchableInterface @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterface(id: ID!): RefetchableInterface | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface implements RefetchableInterface & Node { | ||
id: ID! | ||
} | ||
|
||
type ConcreteType2ImplementingRefetchableInterface implements RefetchableInterface { | ||
id: ID! | ||
} | ||
|
92 changes: 92 additions & 0 deletions
92
...rates/relay-transforms/tests/refetchable_fragment/fixtures/refetchable-interface.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,92 @@ | ||
==================================== INPUT ==================================== | ||
fragment RefetchableFragment on RefetchableInterface | ||
@refetchable(queryName: "RefetchableFragmentQuery") { | ||
id | ||
} | ||
|
||
fragment RefetchableFragment2 on RefetchableInterface2 | ||
@refetchable(queryName: "RefetchableFragmentQuery2") { | ||
__typename | ||
} | ||
|
||
# %extensions% | ||
|
||
interface RefetchableInterface @fetchable(field_name: "id") { | ||
id: ID! | ||
} | ||
|
||
interface RefetchableInterface2 @fetchable(field_name: "not_id") { | ||
not_id: ID! | ||
} | ||
|
||
extend type Query { | ||
fetch__RefetchableInterface(id: ID!): RefetchableInterface | ||
fetch__RefetchableInterface2(id: ID!): RefetchableInterface2 | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface implements RefetchableInterface { | ||
id: ID! | ||
} | ||
|
||
type ConcreteTypeImplementingRefetchableInterface2 implements RefetchableInterface2 { | ||
not_id: ID! | ||
} | ||
==================================== OUTPUT =================================== | ||
query RefetchableFragmentQuery( | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragment", | ||
# ), | ||
# ) | ||
{ | ||
fetch__RefetchableInterface(id: $id) { | ||
...RefetchableFragment | ||
} | ||
} | ||
|
||
query RefetchableFragmentQuery2( | ||
$id: ID! | ||
) @__RefetchableDerivedFromMetadata | ||
# RefetchableDerivedFromMetadata( | ||
# FragmentDefinitionName( | ||
# "RefetchableFragment2", | ||
# ), | ||
# ) | ||
{ | ||
fetch__RefetchableInterface2(id: $id) { | ||
...RefetchableFragment2 | ||
} | ||
} | ||
|
||
fragment RefetchableFragment on RefetchableInterface @refetchable(queryName: "RefetchableFragmentQuery") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: "RefetchableFragmentQuery", | ||
# path: [ | ||
# "fetch__RefetchableInterface", | ||
# ], | ||
# identifier_field: Some( | ||
# "id", | ||
# ), | ||
# } | ||
{ | ||
id | ||
__token | ||
} | ||
|
||
fragment RefetchableFragment2 on RefetchableInterface2 @refetchable(queryName: "RefetchableFragmentQuery2") @__RefetchableMetadata | ||
# RefetchableMetadata { | ||
# operation_name: "RefetchableFragmentQuery2", | ||
# path: [ | ||
# "fetch__RefetchableInterface2", | ||
# ], | ||
# identifier_field: Some( | ||
# "not_id", | ||
# ), | ||
# } | ||
{ | ||
__typename | ||
not_id | ||
__token | ||
} |
Oops, something went wrong.