-
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.
Allow resolvers with @rootFragment on model types
Reviewed By: davidmccabe Differential Revision: D45199425 fbshipit-source-id: 9096deaedcca3652488554117c32a5936d8d57a2
- Loading branch information
1 parent
123dd0a
commit fccb3c8
Showing
11 changed files
with
630 additions
and
5 deletions.
There are no files selected for viewing
216 changes: 216 additions & 0 deletions
216
...tests/compile_relay_artifacts/fixtures/resolver-with-root-fragment-on-model-type.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,216 @@ | ||
==================================== INPUT ==================================== | ||
query resolverWithRootFragmentOnModelType_Query { | ||
my_type { | ||
my_field | ||
} | ||
} | ||
|
||
fragment resolverWithRootFragmentOnModelTypeRootFragment on MyType { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
type MyType @__RelayResolverModel { | ||
id: ID! | ||
__relay_model_instance: Int | ||
@relay_resolver( | ||
import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js" | ||
fragment_name: "MyType__id" | ||
inject_fragment_data: "id" | ||
import_name: "MyType" | ||
) | ||
@unselectable( | ||
reason: "This field is intended only for Relay's internal use" | ||
) | ||
} | ||
|
||
extend type MyType { | ||
my_field: String | ||
@relay_resolver( | ||
import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js" | ||
fragment_name: "resolverWithRootFragmentOnModelTypeRootFragment" | ||
has_output_type: true | ||
import_name: "my_field" | ||
) | ||
} | ||
|
||
extend type Query { | ||
my_type: MyType | ||
} | ||
==================================== OUTPUT =================================== | ||
{ | ||
"fragment": { | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "resolverWithRootFragmentOnModelType_Query", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"concreteType": "MyType", | ||
"kind": "LinkedField", | ||
"name": "my_type", | ||
"plural": false, | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"fragment": { | ||
"args": null, | ||
"kind": "FragmentSpread", | ||
"name": "resolverWithRootFragmentOnModelTypeRootFragment" | ||
}, | ||
"kind": "RelayResolver", | ||
"name": "my_field", | ||
"resolverModule": require('terse-relay-resolver-with-root-fragment-on-model').my_field, | ||
"path": "my_type.my_field" | ||
} | ||
], | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
], | ||
"type": "Query", | ||
"abstractKey": null | ||
}, | ||
"kind": "Request", | ||
"operation": { | ||
"argumentDefinitions": [], | ||
"kind": "Operation", | ||
"name": "resolverWithRootFragmentOnModelType_Query", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"concreteType": "MyType", | ||
"kind": "LinkedField", | ||
"name": "my_type", | ||
"plural": false, | ||
"selections": [ | ||
{ | ||
"name": "my_field", | ||
"args": null, | ||
"fragment": { | ||
"kind": "InlineFragment", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "id", | ||
"storageKey": null | ||
} | ||
], | ||
"type": "MyType", | ||
"abstractKey": null | ||
}, | ||
"kind": "RelayResolver", | ||
"storageKey": null, | ||
"isOutputType": true | ||
}, | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "id", | ||
"storageKey": null | ||
} | ||
], | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"params": { | ||
"cacheID": "6a469c8af9ccbc6879fcb39a2bff5b2e", | ||
"id": null, | ||
"metadata": {}, | ||
"name": "resolverWithRootFragmentOnModelType_Query", | ||
"operationKind": "query", | ||
"text": null | ||
} | ||
} | ||
|
||
QUERY: | ||
|
||
Query Text is Empty. | ||
|
||
{ | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "MyType____relay_model_instance", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"fragment": { | ||
"args": null, | ||
"kind": "FragmentSpread", | ||
"name": "MyType__id" | ||
}, | ||
"kind": "RelayResolver", | ||
"name": "__relay_model_instance", | ||
"resolverModule": require('relay-runtime/experimental').resolverDataInjector(require('MyType__id.graphql'), require('terse-relay-resolver-with-root-fragment-on-model').MyType, 'id', true), | ||
"path": "__relay_model_instance" | ||
} | ||
], | ||
"type": "MyType", | ||
"abstractKey": null | ||
} | ||
|
||
{ | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "MyType__id", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "id", | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
], | ||
"type": "MyType", | ||
"abstractKey": null | ||
} | ||
|
||
{ | ||
"argumentDefinitions": [], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "resolverWithRootFragmentOnModelTypeRootFragment", | ||
"selections": [ | ||
{ | ||
"kind": "ClientExtension", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "id", | ||
"storageKey": null | ||
} | ||
] | ||
} | ||
], | ||
"type": "MyType", | ||
"abstractKey": null | ||
} |
39 changes: 39 additions & 0 deletions
39
.../tests/compile_relay_artifacts/fixtures/resolver-with-root-fragment-on-model-type.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,39 @@ | ||
query resolverWithRootFragmentOnModelType_Query { | ||
my_type { | ||
my_field | ||
} | ||
} | ||
|
||
fragment resolverWithRootFragmentOnModelTypeRootFragment on MyType { | ||
id | ||
} | ||
|
||
# %extensions% | ||
|
||
type MyType @__RelayResolverModel { | ||
id: ID! | ||
__relay_model_instance: Int | ||
@relay_resolver( | ||
import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js" | ||
fragment_name: "MyType__id" | ||
inject_fragment_data: "id" | ||
import_name: "MyType" | ||
) | ||
@unselectable( | ||
reason: "This field is intended only for Relay's internal use" | ||
) | ||
} | ||
|
||
extend type MyType { | ||
my_field: String | ||
@relay_resolver( | ||
import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js" | ||
fragment_name: "resolverWithRootFragmentOnModelTypeRootFragment" | ||
has_output_type: true | ||
import_name: "my_field" | ||
) | ||
} | ||
|
||
extend type Query { | ||
my_type: MyType | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...cblock/tests/to_schema/fixtures/terse-relay-resolver-with-root-fragment-on-model.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,32 @@ | ||
==================================== 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. | ||
*/ | ||
|
||
/** | ||
* @RelayResolver MyType | ||
*/ | ||
|
||
/** | ||
* @RelayResolver MyType.my_field: String | ||
* @rootFragment myRootFragment | ||
*/ | ||
|
||
graphql` | ||
fragment myRootFragment on MyType { | ||
id | ||
} | ||
` | ||
==================================== OUTPUT =================================== | ||
type MyType @__RelayResolverModel { | ||
id: ID! | ||
__relay_model_instance: Int @relay_resolver(import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js", fragment_name: "MyType__id", inject_fragment_data: "id", import_name: "MyType") @unselectable(reason: "This field is intended only for Relay's internal use") | ||
} | ||
|
||
|
||
extend type MyType { | ||
my_field: String @relay_resolver(import_path: "/path/to/test/fixture/terse-relay-resolver-with-root-fragment-on-model.js", fragment_name: "myRootFragment", has_output_type: true, import_name: "my_field") | ||
} |
21 changes: 21 additions & 0 deletions
21
...lay-docblock/tests/to_schema/fixtures/terse-relay-resolver-with-root-fragment-on-model.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,21 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @RelayResolver MyType | ||
*/ | ||
|
||
/** | ||
* @RelayResolver MyType.my_field: String | ||
* @rootFragment myRootFragment | ||
*/ | ||
|
||
graphql` | ||
fragment myRootFragment on MyType { | ||
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
Oops, something went wrong.