-
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.
Support live resolvers that whant to return @weak type
Summary: For live resolvers that what to return weak object our `weakObjectWrapper` was not fully correct. We need to wrap the result of the `read` function. This diff changes the LiveState value, by wrapping `read` into `weakObjectWrapper` HOC. Reviewed By: captbaritone Differential Revision: D41037791 fbshipit-source-id: fba126cda7fe12343cbb643f42b0e963460d9cc3
- Loading branch information
1 parent
d0afc51
commit 500d91b
Showing
14 changed files
with
558 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ pub enum Primitive { | |
resolver: Box<Primitive>, | ||
key: StringKey, | ||
plural: bool, | ||
live: bool, | ||
}, | ||
} | ||
|
||
|
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
166 changes: 166 additions & 0 deletions
166
...-compiler/tests/compile_relay_artifacts/fixtures/relay-resolver-live-weak-object.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,166 @@ | ||
==================================== INPUT ==================================== | ||
query relayResolverLiveWeakObject_Query { | ||
client_types { | ||
__typename | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
scalar MyClientTypeModel @__RelayCustomScalar(path: "/path/to/test/fixture/weak-type.js", export_name: "MyClientType") | ||
|
||
type MyClientType @__RelayResolverModel @RelayOutputType @__RelayWeakObject { | ||
__relay_model_instance: MyClientTypeModel | ||
} | ||
|
||
extend type Query { | ||
client_types: MyClientType @relay_resolver( | ||
fragment_name: "MyClientType____relay_model_instance" | ||
import_path: "./path/to/ClientTypeResolver.js" | ||
has_output_type: true | ||
live: true, | ||
) | ||
} | ||
==================================== OUTPUT =================================== | ||
{ | ||
"kind": "SplitOperation", | ||
"metadata": {}, | ||
"name": "Query__client_types$normalization", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "__relay_model_instance", | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
{ | ||
"fragment": { | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": { | ||
"hasClientEdges": true | ||
}, | ||
"name": "relayResolverLiveWeakObject_Query", | ||
"selections": [ | ||
{ | ||
"kind": "ClientEdgeToClientObject", | ||
"concreteType": "MyClientType", | ||
"backingField": { | ||
"alias": null, | ||
"args": null, | ||
"fragment": { | ||
"args": null, | ||
"kind": "FragmentSpread", | ||
"name": "MyClientType____relay_model_instance" | ||
}, | ||
"kind": "RelayLiveResolver", | ||
"name": "client_types", | ||
"resolverModule": require('relay-runtime/experimental').weakObjectWrapperLive(require('ClientTypeResolver'), '__relay_model_instance', false), | ||
"path": "client_types", | ||
"normalizationInfo": { | ||
"concreteType": "MyClientType", | ||
"plural": false, | ||
"normalizationNode": require('Query__client_types$normalization.graphql') | ||
} | ||
}, | ||
"linkedField": { | ||
"alias": null, | ||
"args": null, | ||
"concreteType": "MyClientType", | ||
"kind": "LinkedField", | ||
"name": "client_types", | ||
"plural": false, | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "__typename", | ||
"storageKey": null | ||
} | ||
], | ||
"storageKey": null | ||
} | ||
} | ||
], | ||
"type": "Query", | ||
"abstractKey": null | ||
}, | ||
"kind": "Request", | ||
"operation": { | ||
"argumentDefinitions": [], | ||
"kind": "Operation", | ||
"name": "relayResolverLiveWeakObject_Query", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"name": "client_types", | ||
"args": null, | ||
"fragment": { | ||
"kind": "InlineFragment", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "__relay_model_instance", | ||
"storageKey": null | ||
} | ||
], | ||
"type": "MyClientType", | ||
"abstractKey": null | ||
}, | ||
"kind": "RelayResolver", | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"params": { | ||
"cacheID": "b9f4901608de1ebafc06cb1f4ecaec9a", | ||
"id": null, | ||
"metadata": {}, | ||
"name": "relayResolverLiveWeakObject_Query", | ||
"operationKind": "query", | ||
"text": null | ||
} | ||
} | ||
|
||
QUERY: | ||
|
||
Query Text is Empty. | ||
|
||
{ | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "MyClientType____relay_model_instance", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "__relay_model_instance", | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
], | ||
"type": "MyClientType", | ||
"abstractKey": null | ||
} |
22 changes: 22 additions & 0 deletions
22
...y-compiler/tests/compile_relay_artifacts/fixtures/relay-resolver-live-weak-object.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,22 @@ | ||
query relayResolverLiveWeakObject_Query { | ||
client_types { | ||
__typename | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
scalar MyClientTypeModel @__RelayCustomScalar(path: "/path/to/test/fixture/weak-type.js", export_name: "MyClientType") | ||
|
||
type MyClientType @__RelayResolverModel @RelayOutputType @__RelayWeakObject { | ||
__relay_model_instance: MyClientTypeModel | ||
} | ||
|
||
extend type Query { | ||
client_types: MyClientType @relay_resolver( | ||
fragment_name: "MyClientType____relay_model_instance" | ||
import_path: "./path/to/ClientTypeResolver.js" | ||
has_output_type: true | ||
live: true, | ||
) | ||
} |
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.