-
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.
Reviewed By: evanyeung Differential Revision: D58156313 fbshipit-source-id: 776c27e1f120e808320cbe0f789f2f808900d816
- Loading branch information
1 parent
722b18f
commit 8cce449
Showing
6 changed files
with
298 additions
and
3 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
229 changes: 229 additions & 0 deletions
229
...ates/relay-schema-generation/tests/docblock/fixtures/return-relay-resolver-value.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,229 @@ | ||
==================================== INPUT ==================================== | ||
//- module.js | ||
|
||
/** | ||
* 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. | ||
*/ | ||
|
||
import type CatFlowType from 'Cat'; | ||
|
||
import type { RelayResolverValue } from 'relay-runtime'; | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function Cat(id: DataID): CatFlowType { | ||
return {}; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function complexValue(cat: CatFlowType): RelayResolverValue<{a: 1, b: 2}> { | ||
return {a: 1, b: 2}; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function optionalRelayResolverValue(cat: CatFlowType): ?RelayResolverValue<{a: 1, b: 2}> { | ||
return null; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function relayResolveValueOverridesAllOtherAnnotation(cat: CatFlowType): ?RelayResolverValue<IdOf<"Cat">> { | ||
return {id: '1'}; | ||
} | ||
==================================== OUTPUT =================================== | ||
Field( | ||
TerseRelayResolver( | ||
TerseRelayResolverIr { | ||
field: FieldDefinition { | ||
name: Identifier { | ||
span: 419:431, | ||
token: Token { | ||
span: 419:431, | ||
kind: Identifier, | ||
}, | ||
value: "complexValue", | ||
}, | ||
type_: Named( | ||
NamedTypeAnnotation { | ||
name: Identifier { | ||
span: 451:483, | ||
token: Token { | ||
span: 451:483, | ||
kind: Identifier, | ||
}, | ||
value: "RelayResolverValue", | ||
}, | ||
}, | ||
), | ||
arguments: None, | ||
directives: [], | ||
description: None, | ||
hack_source: None, | ||
span: 419:431, | ||
}, | ||
type_: WithLocation { | ||
location: <generated>:330:333, | ||
item: "Cat", | ||
}, | ||
root_fragment: None, | ||
deprecated: None, | ||
semantic_non_null: None, | ||
live: None, | ||
location: module.js:419:431, | ||
fragment_arguments: None, | ||
source_hash: ResolverSourceHash( | ||
"fc15c065174264428a3632fe9cf329d6", | ||
), | ||
}, | ||
), | ||
) | ||
extend type Cat { | ||
complexValue: RelayResolverValue @relay_resolver(fragment_name: "Cat____relay_model_instance", generated_fragment: true, inject_fragment_data: "__relay_model_instance", has_output_type: true, import_name: "complexValue", import_path: "module.js") @resolver_source_hash(value: "fc15c065174264428a3632fe9cf329d6") | ||
} | ||
|
||
|
||
Field( | ||
TerseRelayResolver( | ||
TerseRelayResolverIr { | ||
field: FieldDefinition { | ||
name: Identifier { | ||
span: 554:580, | ||
token: Token { | ||
span: 554:580, | ||
kind: Identifier, | ||
}, | ||
value: "optionalRelayResolverValue", | ||
}, | ||
type_: Named( | ||
NamedTypeAnnotation { | ||
name: Identifier { | ||
span: 601:633, | ||
token: Token { | ||
span: 601:633, | ||
kind: Identifier, | ||
}, | ||
value: "RelayResolverValue", | ||
}, | ||
}, | ||
), | ||
arguments: None, | ||
directives: [], | ||
description: None, | ||
hack_source: None, | ||
span: 554:580, | ||
}, | ||
type_: WithLocation { | ||
location: <generated>:330:333, | ||
item: "Cat", | ||
}, | ||
root_fragment: None, | ||
deprecated: None, | ||
semantic_non_null: None, | ||
live: None, | ||
location: module.js:554:580, | ||
fragment_arguments: None, | ||
source_hash: ResolverSourceHash( | ||
"fc15c065174264428a3632fe9cf329d6", | ||
), | ||
}, | ||
), | ||
) | ||
extend type Cat { | ||
optionalRelayResolverValue: RelayResolverValue @relay_resolver(fragment_name: "Cat____relay_model_instance", generated_fragment: true, inject_fragment_data: "__relay_model_instance", has_output_type: true, import_name: "optionalRelayResolverValue", import_path: "module.js") @resolver_source_hash(value: "fc15c065174264428a3632fe9cf329d6") | ||
} | ||
|
||
|
||
Field( | ||
TerseRelayResolver( | ||
TerseRelayResolverIr { | ||
field: FieldDefinition { | ||
name: Identifier { | ||
span: 696:740, | ||
token: Token { | ||
span: 696:740, | ||
kind: Identifier, | ||
}, | ||
value: "relayResolveValueOverridesAllOtherAnnotation", | ||
}, | ||
type_: Named( | ||
NamedTypeAnnotation { | ||
name: Identifier { | ||
span: 761:792, | ||
token: Token { | ||
span: 761:792, | ||
kind: Identifier, | ||
}, | ||
value: "RelayResolverValue", | ||
}, | ||
}, | ||
), | ||
arguments: None, | ||
directives: [], | ||
description: None, | ||
hack_source: None, | ||
span: 696:740, | ||
}, | ||
type_: WithLocation { | ||
location: <generated>:330:333, | ||
item: "Cat", | ||
}, | ||
root_fragment: None, | ||
deprecated: None, | ||
semantic_non_null: None, | ||
live: None, | ||
location: module.js:696:740, | ||
fragment_arguments: None, | ||
source_hash: ResolverSourceHash( | ||
"fc15c065174264428a3632fe9cf329d6", | ||
), | ||
}, | ||
), | ||
) | ||
extend type Cat { | ||
relayResolveValueOverridesAllOtherAnnotation: RelayResolverValue @relay_resolver(fragment_name: "Cat____relay_model_instance", generated_fragment: true, inject_fragment_data: "__relay_model_instance", has_output_type: true, import_name: "relayResolveValueOverridesAllOtherAnnotation", import_path: "module.js") @resolver_source_hash(value: "fc15c065174264428a3632fe9cf329d6") | ||
} | ||
|
||
|
||
Type( | ||
StrongObjectResolver( | ||
StrongObjectIr { | ||
type_name: Identifier { | ||
span: 330:333, | ||
token: Token { | ||
span: 330:333, | ||
kind: Identifier, | ||
}, | ||
value: "Cat", | ||
}, | ||
rhs_location: module.js:330:333, | ||
root_fragment: WithLocation { | ||
location: module.js:330:333, | ||
item: FragmentDefinitionName( | ||
"Cat__id", | ||
), | ||
}, | ||
description: None, | ||
deprecated: None, | ||
live: None, | ||
semantic_non_null: None, | ||
location: module.js:330:333, | ||
implements_interfaces: [], | ||
source_hash: ResolverSourceHash( | ||
"fc15c065174264428a3632fe9cf329d6", | ||
), | ||
}, | ||
), | ||
) | ||
type Cat @__RelayResolverModel { | ||
id: ID! | ||
__relay_model_instance: RelayResolverValue! @relay_resolver(generated_fragment: true, fragment_name: "Cat__id", import_name: "Cat", import_path: "module.js", inject_fragment_data: "id") @resolver_source_hash(value: "fc15c065174264428a3632fe9cf329d6") @unselectable(reason: "This field is intended only for Relay's internal use") | ||
} |
40 changes: 40 additions & 0 deletions
40
.../crates/relay-schema-generation/tests/docblock/fixtures/return-relay-resolver-value.input
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,40 @@ | ||
//- module.js | ||
|
||
/** | ||
* 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. | ||
*/ | ||
|
||
import type CatFlowType from 'Cat'; | ||
|
||
import type { RelayResolverValue } from 'relay-runtime'; | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function Cat(id: DataID): CatFlowType { | ||
return {}; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function complexValue(cat: CatFlowType): RelayResolverValue<{a: 1, b: 2}> { | ||
return {a: 1, b: 2}; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function optionalRelayResolverValue(cat: CatFlowType): ?RelayResolverValue<{a: 1, b: 2}> { | ||
return null; | ||
} | ||
|
||
/** | ||
* @RelayResolver | ||
*/ | ||
export function relayResolveValueOverridesAllOtherAnnotation(cat: CatFlowType): ?RelayResolverValue<IdOf<"Cat">> { | ||
return {id: '1'}; | ||
} |
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