-
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.
Compiler flag to enable named imports
Summary: If this feature flag is enabled, we'll use named imports for resolver functions. This will allow us define multiple resolvers in a single file. In this diff we passing this flag to the relay docblock parser, so it can start adding field name (for now) as a `named` import. In the next diff this `import_name` will be used in codegen/typegen. Reviewed By: captbaritone Differential Revision: D40240874 fbshipit-source-id: 7944ee65a52bcbcb6b5edc305c15ae6c2cce561f
- Loading branch information
1 parent
9065f2a
commit 9d3a87d
Showing
25 changed files
with
288 additions
and
14 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
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
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
75 changes: 75 additions & 0 deletions
75
compiler/crates/relay-docblock/tests/parse/fixtures/relay-resolver-named-export.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,75 @@ | ||
==================================== INPUT ==================================== | ||
/** | ||
* 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. | ||
*/ | ||
|
||
// relay:use_named_imports | ||
|
||
/** | ||
* @RelayResolver | ||
* | ||
* @onType User | ||
* @fieldName favorite_page | ||
* @rootFragment myRootFragment | ||
* | ||
* The user's favorite page! They probably clicked something in the UI | ||
* to tell us that it was their favorite page and then we put that in a | ||
* database or something. Then we got that info out again and put it out | ||
* again. Anyway, I'm rambling now. Its a page that the user likes. A lot. | ||
*/ | ||
|
||
graphql` | ||
fragment myRootFragment on User { | ||
id | ||
} | ||
` | ||
==================================== OUTPUT =================================== | ||
RelayResolver( | ||
RelayResolverIr { | ||
field: FieldDefinitionStub { | ||
name: Identifier { | ||
span: 53:66, | ||
token: Token { | ||
span: 53:66, | ||
kind: Identifier, | ||
}, | ||
value: "favorite_page", | ||
}, | ||
arguments: None, | ||
}, | ||
on: Type( | ||
PopulatedIrField { | ||
key_location: /path/to/test/fixture/relay-resolver-named-export.js:27:33, | ||
value: WithLocation { | ||
location: /path/to/test/fixture/relay-resolver-named-export.js:34:38, | ||
item: "User", | ||
}, | ||
}, | ||
), | ||
root_fragment: Some( | ||
WithLocation { | ||
location: /path/to/test/fixture/relay-resolver-named-export.js:84:98, | ||
item: FragmentDefinitionName( | ||
"myRootFragment", | ||
), | ||
}, | ||
), | ||
output_type: None, | ||
description: Some( | ||
WithLocation { | ||
location: /path/to/test/fixture/relay-resolver-named-export.js:101:392, | ||
item: "\nThe user's favorite page! They probably clicked something in the UI\nto tell us that it was their favorite page and then we put that in a\ndatabase or something. Then we got that info out again and put it out\nagain. Anyway, I'm rambling now. Its a page that the user likes. A lot.", | ||
}, | ||
), | ||
deprecated: None, | ||
live: None, | ||
location: /path/to/test/fixture/relay-resolver-named-export.js:0:393, | ||
fragment_arguments: None, | ||
named_import: Some( | ||
"favorite_page", | ||
), | ||
}, | ||
) |
27 changes: 27 additions & 0 deletions
27
compiler/crates/relay-docblock/tests/parse/fixtures/relay-resolver-named-export.js
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. | ||
*/ | ||
|
||
// relay:use_named_imports | ||
|
||
/** | ||
* @RelayResolver | ||
* | ||
* @onType User | ||
* @fieldName favorite_page | ||
* @rootFragment myRootFragment | ||
* | ||
* The user's favorite page! They probably clicked something in the UI | ||
* to tell us that it was their favorite page and then we put that in a | ||
* database or something. Then we got that info out again and put it out | ||
* again. Anyway, I'm rambling now. Its a page that the user likes. A lot. | ||
*/ | ||
|
||
graphql` | ||
fragment myRootFragment on User { | ||
id | ||
} | ||
` |
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 |
---|---|---|
|
@@ -134,5 +134,6 @@ RelayResolver( | |
}, | ||
], | ||
), | ||
named_import: None, | ||
}, | ||
) |
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 |
---|---|---|
|
@@ -172,5 +172,6 @@ RelayResolver( | |
}, | ||
], | ||
), | ||
named_import: None, | ||
}, | ||
) |
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
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
Oops, something went wrong.