diff --git a/packages/react-relay/__tests__/RelayResolverNullableModelClientEdge-test.js b/packages/react-relay/__tests__/RelayResolverNullableModelClientEdge-test.js new file mode 100644 index 0000000000000..299fc0bf67363 --- /dev/null +++ b/packages/react-relay/__tests__/RelayResolverNullableModelClientEdge-test.js @@ -0,0 +1,339 @@ +/** + * 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. + * + * @flow strict-local + * @format + * @oncall relay + */ + +import type {DataID, LogEvent} from 'relay-runtime'; +import type {RelayMockEnvironment} from 'relay-test-utils'; + +const invariant = require('invariant'); +const React = require('react'); +const { + RelayEnvironmentProvider, + useClientQuery, + useFragment: useFragment_LEGACY, +} = require('react-relay'); +const useFragment_EXPERIMENTAL = require('react-relay/relay-hooks/experimental/useFragment_EXPERIMENTAL'); +const TestRenderer = require('react-test-renderer'); +const { + __internal, + Environment, + Network, + RecordSource, + RelayFeatureFlags, + graphql, +} = require('relay-runtime'); +const LiveResolverStore = require('relay-runtime/store/experimental-live-resolvers/LiveResolverStore'); +const {createMockEnvironment} = require('relay-test-utils'); + +/** + * CLIENT EDGE TO LIVE STRONG CLIENT OBJECT + */ + +/** + * @RelayResolver Query.edge_to_live_object_does_not_exist: TodoModel + */ +export function edge_to_live_object_does_not_exist(): {id: DataID} { + return {id: 'THERE_IS_NO_TODO_WITH_THIS_ID'}; +} + +/** + * CLIENT EDGE TO WEAK CLIENT OBJECT + */ + +/** + * @RelayResolver WeakModel + * @weak + */ +export type WeakModel = { + firstName: string, + lastName: string, +}; + +/** + * @RelayResolver Query.edge_to_null_weak_model: WeakModel + */ +export function edge_to_null_weak_model(): ?WeakModel { + return null; +} + +/** + * @RelayResolver WeakModel.first_name: String + */ +export function first_name(model: WeakModel): string { + return model.firstName; +} + +/** + * CLIENT EDGE TO STRONG CLIENT OBJECT + */ + +type StrongModelType = ?{ + id: string, + name: string, +}; + +/** + * @RelayResolver StrongModel + */ +export function StrongModel(id: string): StrongModelType { + return null; +} + +/** + * @RelayResolver StrongModel.name: String + */ +export function name(model: StrongModelType): ?string { + return model?.name; +} + +/** + * @RelayResolver Query.edge_to_strong_model_does_not_exist: StrongModel + */ +export function edge_to_strong_model_does_not_exist(): {id: DataID} { + return {id: 'THERE_IS_NO_STRONG_MODEL_WITH_THIS_ID'}; +} + +/** + * CLIENT EDGE TO SERVER OBJECT + */ + +/** + * @RelayResolver Query.edge_to_server_object_does_not_exist: Comment + */ +export function edge_to_server_object_does_not_exist(): {id: DataID} { + return {id: 'THERE_IS_NO_COMMENT_WITH_THIS_ID'}; +} + +beforeEach(() => { + RelayFeatureFlags.ENABLE_RELAY_RESOLVERS = true; + RelayFeatureFlags.ENABLE_CLIENT_EDGES = true; +}); + +afterEach(() => { + RelayFeatureFlags.ENABLE_RELAY_RESOLVERS = false; + RelayFeatureFlags.ENABLE_CLIENT_EDGES = false; +}); + +const logEvents: Array = []; +function logFn(event: LogEvent): void { + logEvents.push(event); +} + +function createEnvironment() { + return new Environment({ + network: Network.create(jest.fn()), + store: new LiveResolverStore(RecordSource.create(), { + log: logFn, + }), + log: logFn, + }); +} + +function EnvironmentWrapper({ + children, + environment, +}: { + children: React.Node, + environment: Environment | RelayMockEnvironment, +}) { + return ( + + {children} + + ); +} + +describe.each([ + ['Experimental', useFragment_EXPERIMENTAL], + ['Legacy', useFragment_LEGACY], +])('Hook implementation: %s', (_hookName, useFragment) => { + let environment; + beforeEach(() => { + environment = createEnvironment(); + }); + test('client edge to ID with no corresponding live object', () => { + function TodoNullComponent() { + const data = useClientQuery( + graphql` + query RelayResolverNullableModelClientEdgeTest_LiveModel_Query { + edge_to_live_object_does_not_exist { + id + fancy_description { + text + } + } + } + `, + {}, + ); + + invariant(data != null, 'Query response should be nonnull'); + + switch (data.edge_to_live_object_does_not_exist) { + case null: + return 'Todo was null'; + case undefined: + return 'Todo was undefined'; + default: + return 'Todo was not null or undefined'; + } + } + const renderer = TestRenderer.create( + + + , + ); + // TODO: T162471299 this should be 'Todo was null' + expect(renderer.toJSON()).toEqual('Todo was not null or undefined'); + }); + + test('client edge to ID with no corresponding weak object', () => { + function NullWeakModelComponent() { + const data = useClientQuery( + graphql` + query RelayResolverNullableModelClientEdgeTest_WeakModel_Query { + edge_to_null_weak_model { + first_name + } + } + `, + {}, + ); + + invariant(data != null, 'Query response should be nonnull'); + + switch (data.edge_to_null_weak_model) { + case null: + return 'Weak model was null'; + case undefined: + return 'Weak model was undefined'; + default: + return 'Weak model was not null or undefined'; + } + } + const renderer = TestRenderer.create( + + + , + ); + expect(renderer.toJSON()).toEqual('Weak model was null'); + }); + + test('client edge to ID with no corresponding strong object', () => { + function NullStrongModelComponent() { + const data = useClientQuery( + graphql` + query RelayResolverNullableModelClientEdgeTest_StrongModel_Query { + edge_to_strong_model_does_not_exist { + name + } + } + `, + {}, + ); + + invariant(data != null, 'Query response should be nonnull'); + + switch (data.edge_to_strong_model_does_not_exist) { + case null: + return 'strong model was null'; + case undefined: + return 'strong model was undefined'; + default: + return 'strong model was not null or undefined'; + } + } + const renderer = TestRenderer.create( + + + , + ); + // TODO: T162471299 this should be 'strong model was null' + expect(renderer.toJSON()).toEqual('strong model was not null or undefined'); + }); + + test('client edge to server ID with no corresponding server object', () => { + function NullServerObjectComponent() { + const data = useClientQuery( + graphql` + query RelayResolverNullableModelClientEdgeTest_ServerObject_Query { + edge_to_server_object_does_not_exist @waterfall { + name + } + } + `, + {}, + ); + + invariant(data != null, 'Query response should be nonnull'); + + switch (data.edge_to_server_object_does_not_exist) { + case null: + return 'server object was null'; + case undefined: + return 'server object was undefined'; + default: + return 'server object was not null or undefined'; + } + } + const mock_environment = createMockEnvironment(); + const renderer = TestRenderer.create( + + + , + ); + expect(renderer.toJSON()).toEqual('Loading...'); + TestRenderer.act(() => { + mock_environment.mock.resolveMostRecentOperation({data: {node: null}}); + jest.runAllImmediates(); + }); + // TODO T169274655 should this be 'server object was null'? + expect(renderer.toJSON()).toEqual('server object was undefined'); + }); + + test('client edge to server ID with no corresponding server object (read only id)', () => { + function NullServerObjectComponent() { + const data = useClientQuery( + graphql` + query RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query { + edge_to_server_object_does_not_exist @waterfall { + id + } + } + `, + {}, + ); + + invariant(data != null, 'Query response should be nonnull'); + + switch (data.edge_to_server_object_does_not_exist) { + case null: + return 'server object was null'; + case undefined: + return 'server object was undefined'; + default: + return 'server object was not null or undefined'; + } + } + const mock_environment = createMockEnvironment(); + const renderer = TestRenderer.create( + + + , + ); + expect(renderer.toJSON()).toEqual('Loading...'); + TestRenderer.act(() => { + mock_environment.mock.resolveMostRecentOperation({data: {node: null}}); + jest.runAllImmediates(); + }); + // TODO T169274655 should this be 'server object was null'? + expect(renderer.toJSON()).toEqual('server object was undefined'); + }); +}); diff --git a/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js b/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js new file mode 100644 index 0000000000000..b042b1e398240 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js @@ -0,0 +1,129 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<9151cadaf4abeb5c370580eca29aa399>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ConcreteRequest, Query } from 'relay-runtime'; +import type { RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType } from "./RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql"; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$variables = {| + id: string, +|}; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data = {| + +node: ?{| + +$fragmentSpreads: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType, + |}, +|}; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist = {| + response: ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data, + variables: ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$variables, +|}; +*/ + +var node/*: ConcreteRequest*/ = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "id" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "id" + } +]; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist" + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "3b1b145feebb57a5f456912d1a263861", + "id": null, + "metadata": {}, + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist", + "operationKind": "query", + "text": "query ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist(\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist\n id\n }\n}\n\nfragment RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist on Comment {\n id\n}\n" + } +}; +})(); + +if (__DEV__) { + (node/*: any*/).hash = "6e6fc82ab5969e84d7c748516d16686b"; +} + +module.exports = ((node/*: any*/)/*: Query< + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$variables, + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js b/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js new file mode 100644 index 0000000000000..bb0b4fa8e6d18 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js @@ -0,0 +1,143 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<95edd3dfa81abb8b0e4eb82a16139e95>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ConcreteRequest, Query } from 'relay-runtime'; +import type { RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType } from "./RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql"; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$variables = {| + id: string, +|}; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data = {| + +node: ?{| + +$fragmentSpreads: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType, + |}, +|}; +export type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist = {| + response: ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data, + variables: ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$variables, +|}; +*/ + +var node/*: ConcreteRequest*/ = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "id" + } +], +v1 = [ + { + "kind": "Variable", + "name": "id", + "variableName": "id" + } +]; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist" + } + ], + "storageKey": null + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": null, + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + }, + { + "kind": "InlineFragment", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "name", + "storageKey": null + } + ], + "type": "Comment", + "abstractKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "661ce80f22fca05217a32fb3b9639774", + "id": null, + "metadata": {}, + "name": "ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist", + "operationKind": "query", + "text": "query ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist(\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist\n id\n }\n}\n\nfragment RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist on Comment {\n name\n id\n}\n" + } +}; +})(); + +if (__DEV__) { + (node/*: any*/).hash = "3990dc068bf228226a21832b04bbd39a"; +} + +module.exports = ((node/*: any*/)/*: Query< + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$variables, + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/Query__edge_to_null_weak_model$normalization.graphql.js b/packages/react-relay/__tests__/__generated__/Query__edge_to_null_weak_model$normalization.graphql.js new file mode 100644 index 0000000000000..33699bd326564 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/Query__edge_to_null_weak_model$normalization.graphql.js @@ -0,0 +1,49 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<389a4bbc5d675d03a80c8e0815b91668>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { NormalizationSplitOperation } from 'relay-runtime'; + +import type { WeakModel } from "../RelayResolverNullableModelClientEdge-test.js"; +export type Query__edge_to_null_weak_model$normalization = {| + +__relay_model_instance: WeakModel, +|}; + +*/ + +var node/*: NormalizationSplitOperation*/ = { + "kind": "SplitOperation", + "metadata": {}, + "name": "Query__edge_to_null_weak_model$normalization", + "selections": [ + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__relay_model_instance", + "storageKey": null + } + ] + } + ] +}; + +module.exports = node; diff --git a/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js b/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js new file mode 100644 index 0000000000000..eb3c4898a1870 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql.js @@ -0,0 +1,73 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ReaderFragment, RefetchableFragment } from 'relay-runtime'; +import type { FragmentType } from "relay-runtime"; +declare export opaque type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType: FragmentType; +type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$variables = any; +export type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data = {| + +id: string, + +$fragmentType: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType, +|}; +export type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$key = { + +$data?: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data, + +$fragmentSpreads: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType, + ... +}; +*/ + +var node/*: ReaderFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "refetch": { + "connection": null, + "fragmentPathInResult": [ + "node" + ], + "operation": require('./ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql'), + "identifierInfo": { + "identifierField": "id", + "identifierQueryVariableName": "id" + } + } + }, + "name": "RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ], + "type": "Comment", + "abstractKey": null +}; + +if (__DEV__) { + (node/*: any*/).hash = "6e6fc82ab5969e84d7c748516d16686b"; +} + +module.exports = ((node/*: any*/)/*: RefetchableFragment< + RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$fragmentType, + RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$data, + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist$variables, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js b/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js new file mode 100644 index 0000000000000..55d3325a38ba2 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql.js @@ -0,0 +1,81 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<011095a988ef3a992d94871df730045c>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ReaderFragment, RefetchableFragment } from 'relay-runtime'; +import type { FragmentType } from "relay-runtime"; +declare export opaque type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType: FragmentType; +type ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$variables = any; +export type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data = {| + +id: string, + +name: ?string, + +$fragmentType: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType, +|}; +export type RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$key = { + +$data?: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data, + +$fragmentSpreads: RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType, + ... +}; +*/ + +var node/*: ReaderFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "refetch": { + "connection": null, + "fragmentPathInResult": [ + "node" + ], + "operation": require('./ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql'), + "identifierInfo": { + "identifierField": "id", + "identifierQueryVariableName": "id" + } + } + }, + "name": "RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "name", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ], + "type": "Comment", + "abstractKey": null +}; + +if (__DEV__) { + (node/*: any*/).hash = "3990dc068bf228226a21832b04bbd39a"; +} + +module.exports = ((node/*: any*/)/*: RefetchableFragment< + RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$fragmentType, + RefetchableClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$data, + ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist$variables, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_LiveModel_Query.graphql.js b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_LiveModel_Query.graphql.js new file mode 100644 index 0000000000000..7ec199dd8f0c2 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_LiveModel_Query.graphql.js @@ -0,0 +1,264 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<7c49d4f0a9493239580668b7301b444e>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { DataID } from "relay-runtime"; +import type { TodoDescription____relay_model_instance$data } from "./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoDescription____relay_model_instance.graphql"; +import type { TodoModel____relay_model_instance$data } from "./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoModel____relay_model_instance.graphql"; +import {edge_to_live_object_does_not_exist as queryEdgeToLiveObjectDoesNotExistResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `queryEdgeToLiveObjectDoesNotExistResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(queryEdgeToLiveObjectDoesNotExistResolverType: () => ?{| + +id: DataID, +|}); +import {text as todoDescriptionTextResolverType} from "../../../relay-runtime/store/__tests__/resolvers/TodoDescription.js"; +// Type assertion validating that `todoDescriptionTextResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(todoDescriptionTextResolverType: ( + __relay_model_instance: TodoDescription____relay_model_instance$data['__relay_model_instance'], +) => ?string); +import {fancy_description as todoModelFancyDescriptionResolverType} from "../../../relay-runtime/store/__tests__/resolvers/TodoModel.js"; +// Type assertion validating that `todoModelFancyDescriptionResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(todoModelFancyDescriptionResolverType: ( + __relay_model_instance: TodoModel____relay_model_instance$data['__relay_model_instance'], +) => ?TodoDescription); +import type { TodoModel__fancy_description$normalization } from "./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoModel__fancy_description$normalization.graphql"; +import type { TodoDescription } from "../../../relay-runtime/store/__tests__/resolvers/TodoDescription.js"; +export type RelayResolverNullableModelClientEdgeTest_LiveModel_Query$variables = {||}; +export type RelayResolverNullableModelClientEdgeTest_LiveModel_Query$data = {| + +edge_to_live_object_does_not_exist: ?{| + +fancy_description: ?{| + +text: ?string, + |}, + +id: string, + |}, +|}; +export type RelayResolverNullableModelClientEdgeTest_LiveModel_Query = {| + response: RelayResolverNullableModelClientEdgeTest_LiveModel_Query$data, + variables: RelayResolverNullableModelClientEdgeTest_LiveModel_Query$variables, +|}; +*/ + +var node/*: ClientRequest*/ = (function(){ +var v0 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "hasClientEdges": true + }, + "name": "RelayResolverNullableModelClientEdgeTest_LiveModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "concreteType": "TodoModel", + "backingField": { + "alias": null, + "args": null, + "fragment": null, + "kind": "RelayResolver", + "name": "edge_to_live_object_does_not_exist", + "resolverModule": require('./../RelayResolverNullableModelClientEdge-test').edge_to_live_object_does_not_exist, + "path": "edge_to_live_object_does_not_exist" + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "TodoModel", + "kind": "LinkedField", + "name": "edge_to_live_object_does_not_exist", + "plural": false, + "selections": [ + (v0/*: any*/), + { + "kind": "ClientEdgeToClientObject", + "concreteType": "TodoDescription", + "backingField": { + "alias": null, + "args": null, + "fragment": { + "args": null, + "kind": "FragmentSpread", + "name": "TodoModel____relay_model_instance" + }, + "kind": "RelayResolver", + "name": "fancy_description", + "resolverModule": require('relay-runtime/experimental').weakObjectWrapper(require('relay-runtime/experimental').resolverDataInjector(require('./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoModel____relay_model_instance.graphql'), require('./../../../relay-runtime/store/__tests__/resolvers/TodoModel').fancy_description, '__relay_model_instance', true), '__relay_model_instance', false), + "path": "edge_to_live_object_does_not_exist.fancy_description", + "normalizationInfo": { + "concreteType": "TodoDescription", + "plural": false, + "normalizationNode": require('./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoModel__fancy_description$normalization.graphql') + } + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "TodoDescription", + "kind": "LinkedField", + "name": "fancy_description", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "fragment": { + "args": null, + "kind": "FragmentSpread", + "name": "TodoDescription____relay_model_instance" + }, + "kind": "RelayResolver", + "name": "text", + "resolverModule": require('relay-runtime/experimental').resolverDataInjector(require('./../../../relay-runtime/store/__tests__/resolvers/__generated__/TodoDescription____relay_model_instance.graphql'), require('./../../../relay-runtime/store/__tests__/resolvers/TodoDescription').text, '__relay_model_instance', true), + "path": "edge_to_live_object_does_not_exist.fancy_description.text" + } + ], + "storageKey": null + } + } + ], + "storageKey": null + } + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "RelayResolverNullableModelClientEdgeTest_LiveModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "backingField": { + "name": "edge_to_live_object_does_not_exist", + "args": null, + "fragment": null, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "TodoModel", + "kind": "LinkedField", + "name": "edge_to_live_object_does_not_exist", + "plural": false, + "selections": [ + (v0/*: any*/), + { + "kind": "ClientEdgeToClientObject", + "backingField": { + "name": "fancy_description", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + { + "name": "__relay_model_instance", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + (v0/*: any*/) + ], + "type": "TodoModel", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + } + ], + "type": "TodoModel", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": true + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "TodoDescription", + "kind": "LinkedField", + "name": "fancy_description", + "plural": false, + "selections": [ + { + "name": "text", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__relay_model_instance", + "storageKey": null + } + ], + "type": "TodoDescription", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": true + } + ], + "storageKey": null + } + } + ], + "storageKey": null + } + } + ] + }, + "params": { + "cacheID": "ffc0723de59b6960e0ea5a5599142177", + "id": null, + "metadata": {}, + "name": "RelayResolverNullableModelClientEdgeTest_LiveModel_Query", + "operationKind": "query", + "text": null + } +}; +})(); + +if (__DEV__) { + (node/*: any*/).hash = "37156528a49b790efe6451531de61ea5"; +} + +module.exports = ((node/*: any*/)/*: ClientQuery< + RelayResolverNullableModelClientEdgeTest_LiveModel_Query$variables, + RelayResolverNullableModelClientEdgeTest_LiveModel_Query$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query.graphql.js b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query.graphql.js new file mode 100644 index 0000000000000..70c2ad1aa76c5 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query.graphql.js @@ -0,0 +1,117 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<2930d3741e8380d84e2c6551c5c44285>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { DataID } from "relay-runtime"; +import {edge_to_server_object_does_not_exist as queryEdgeToServerObjectDoesNotExistResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `queryEdgeToServerObjectDoesNotExistResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(queryEdgeToServerObjectDoesNotExistResolverType: () => ?{| + +id: DataID, +|}); +export type RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$variables = {||}; +export type RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$data = {| + +edge_to_server_object_does_not_exist: ?{| + +id: string, + |}, +|}; +export type RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query = {| + response: RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$data, + variables: RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$variables, +|}; +*/ + +var node/*: ClientRequest*/ = { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "hasClientEdges": true + }, + "name": "RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query", + "selections": [ + { + "kind": "ClientEdgeToServerObject", + "operation": require('./ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query_edge_to_server_object_does_not_exist.graphql'), + "backingField": { + "alias": null, + "args": null, + "fragment": null, + "kind": "RelayResolver", + "name": "edge_to_server_object_does_not_exist", + "resolverModule": require('./../RelayResolverNullableModelClientEdge-test').edge_to_server_object_does_not_exist, + "path": "edge_to_server_object_does_not_exist" + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "Comment", + "kind": "LinkedField", + "name": "edge_to_server_object_does_not_exist", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ], + "storageKey": null + } + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query", + "selections": [ + { + "name": "edge_to_server_object_does_not_exist", + "args": null, + "fragment": null, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + } + ] + }, + "params": { + "cacheID": "a0eacb513c2375b74c665f1f47407e41", + "id": null, + "metadata": {}, + "name": "RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query", + "operationKind": "query", + "text": null + } +}; + +if (__DEV__) { + (node/*: any*/).hash = "6e6fc82ab5969e84d7c748516d16686b"; +} + +module.exports = ((node/*: any*/)/*: ClientQuery< + RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$variables, + RelayResolverNullableModelClientEdgeTest_ServerObjectReadOnlyId_Query$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObject_Query.graphql.js b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObject_Query.graphql.js new file mode 100644 index 0000000000000..aabfb729f6502 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_ServerObject_Query.graphql.js @@ -0,0 +1,117 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { DataID } from "relay-runtime"; +import {edge_to_server_object_does_not_exist as queryEdgeToServerObjectDoesNotExistResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `queryEdgeToServerObjectDoesNotExistResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(queryEdgeToServerObjectDoesNotExistResolverType: () => ?{| + +id: DataID, +|}); +export type RelayResolverNullableModelClientEdgeTest_ServerObject_Query$variables = {||}; +export type RelayResolverNullableModelClientEdgeTest_ServerObject_Query$data = {| + +edge_to_server_object_does_not_exist: ?{| + +name: ?string, + |}, +|}; +export type RelayResolverNullableModelClientEdgeTest_ServerObject_Query = {| + response: RelayResolverNullableModelClientEdgeTest_ServerObject_Query$data, + variables: RelayResolverNullableModelClientEdgeTest_ServerObject_Query$variables, +|}; +*/ + +var node/*: ClientRequest*/ = { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "hasClientEdges": true + }, + "name": "RelayResolverNullableModelClientEdgeTest_ServerObject_Query", + "selections": [ + { + "kind": "ClientEdgeToServerObject", + "operation": require('./ClientEdgeQuery_RelayResolverNullableModelClientEdgeTest_ServerObject_Query_edge_to_server_object_does_not_exist.graphql'), + "backingField": { + "alias": null, + "args": null, + "fragment": null, + "kind": "RelayResolver", + "name": "edge_to_server_object_does_not_exist", + "resolverModule": require('./../RelayResolverNullableModelClientEdge-test').edge_to_server_object_does_not_exist, + "path": "edge_to_server_object_does_not_exist" + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "Comment", + "kind": "LinkedField", + "name": "edge_to_server_object_does_not_exist", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "name", + "storageKey": null + } + ], + "storageKey": null + } + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "RelayResolverNullableModelClientEdgeTest_ServerObject_Query", + "selections": [ + { + "name": "edge_to_server_object_does_not_exist", + "args": null, + "fragment": null, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + } + ] + }, + "params": { + "cacheID": "3a648c6908a7a0fa12a1bc4e9b12d362", + "id": null, + "metadata": {}, + "name": "RelayResolverNullableModelClientEdgeTest_ServerObject_Query", + "operationKind": "query", + "text": null + } +}; + +if (__DEV__) { + (node/*: any*/).hash = "3990dc068bf228226a21832b04bbd39a"; +} + +module.exports = ((node/*: any*/)/*: ClientQuery< + RelayResolverNullableModelClientEdgeTest_ServerObject_Query$variables, + RelayResolverNullableModelClientEdgeTest_ServerObject_Query$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_StrongModel_Query.graphql.js b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_StrongModel_Query.graphql.js new file mode 100644 index 0000000000000..f13e1826caf95 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_StrongModel_Query.graphql.js @@ -0,0 +1,183 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { DataID } from "relay-runtime"; +import type { StrongModel____relay_model_instance$data } from "./StrongModel____relay_model_instance.graphql"; +import {edge_to_strong_model_does_not_exist as queryEdgeToStrongModelDoesNotExistResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `queryEdgeToStrongModelDoesNotExistResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(queryEdgeToStrongModelDoesNotExistResolverType: () => ?{| + +id: DataID, +|}); +import {name as strongModelNameResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `strongModelNameResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(strongModelNameResolverType: ( + __relay_model_instance: StrongModel____relay_model_instance$data['__relay_model_instance'], +) => ?string); +export type RelayResolverNullableModelClientEdgeTest_StrongModel_Query$variables = {||}; +export type RelayResolverNullableModelClientEdgeTest_StrongModel_Query$data = {| + +edge_to_strong_model_does_not_exist: ?{| + +name: ?string, + |}, +|}; +export type RelayResolverNullableModelClientEdgeTest_StrongModel_Query = {| + response: RelayResolverNullableModelClientEdgeTest_StrongModel_Query$data, + variables: RelayResolverNullableModelClientEdgeTest_StrongModel_Query$variables, +|}; +*/ + +var node/*: ClientRequest*/ = (function(){ +var v0 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "hasClientEdges": true + }, + "name": "RelayResolverNullableModelClientEdgeTest_StrongModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "concreteType": "StrongModel", + "backingField": { + "alias": null, + "args": null, + "fragment": null, + "kind": "RelayResolver", + "name": "edge_to_strong_model_does_not_exist", + "resolverModule": require('./../RelayResolverNullableModelClientEdge-test').edge_to_strong_model_does_not_exist, + "path": "edge_to_strong_model_does_not_exist" + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "StrongModel", + "kind": "LinkedField", + "name": "edge_to_strong_model_does_not_exist", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "fragment": { + "args": null, + "kind": "FragmentSpread", + "name": "StrongModel____relay_model_instance" + }, + "kind": "RelayResolver", + "name": "name", + "resolverModule": require('relay-runtime/experimental').resolverDataInjector(require('./StrongModel____relay_model_instance.graphql'), require('./../RelayResolverNullableModelClientEdge-test').name, '__relay_model_instance', true), + "path": "edge_to_strong_model_does_not_exist.name" + } + ], + "storageKey": null + } + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "RelayResolverNullableModelClientEdgeTest_StrongModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "backingField": { + "name": "edge_to_strong_model_does_not_exist", + "args": null, + "fragment": null, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "StrongModel", + "kind": "LinkedField", + "name": "edge_to_strong_model_does_not_exist", + "plural": false, + "selections": [ + { + "name": "name", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + { + "name": "__relay_model_instance", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + (v0/*: any*/) + ], + "type": "StrongModel", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": false + } + ], + "type": "StrongModel", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": true + }, + (v0/*: any*/) + ], + "storageKey": null + } + } + ] + }, + "params": { + "cacheID": "acb5dbbcdb10b8c23559acfa09470a62", + "id": null, + "metadata": {}, + "name": "RelayResolverNullableModelClientEdgeTest_StrongModel_Query", + "operationKind": "query", + "text": null + } +}; +})(); + +if (__DEV__) { + (node/*: any*/).hash = "22ad42880cde32f3213c37be50f8dadd"; +} + +module.exports = ((node/*: any*/)/*: ClientQuery< + RelayResolverNullableModelClientEdgeTest_StrongModel_Query$variables, + RelayResolverNullableModelClientEdgeTest_StrongModel_Query$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_WeakModel_Query.graphql.js b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_WeakModel_Query.graphql.js new file mode 100644 index 0000000000000..d9bd1ad2b949b --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/RelayResolverNullableModelClientEdgeTest_WeakModel_Query.graphql.js @@ -0,0 +1,169 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<2fe6a2d3bc6b9c14578dc44ad440dd77>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { WeakModel____relay_model_instance$data } from "./WeakModel____relay_model_instance.graphql"; +import {edge_to_null_weak_model as queryEdgeToNullWeakModelResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `queryEdgeToNullWeakModelResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(queryEdgeToNullWeakModelResolverType: () => ?WeakModel); +import {first_name as weakModelFirstNameResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `weakModelFirstNameResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(weakModelFirstNameResolverType: ( + __relay_model_instance: WeakModel____relay_model_instance$data['__relay_model_instance'], +) => ?string); +import type { Query__edge_to_null_weak_model$normalization } from "./Query__edge_to_null_weak_model$normalization.graphql"; +import type { WeakModel } from "../RelayResolverNullableModelClientEdge-test.js"; +export type RelayResolverNullableModelClientEdgeTest_WeakModel_Query$variables = {||}; +export type RelayResolverNullableModelClientEdgeTest_WeakModel_Query$data = {| + +edge_to_null_weak_model: ?{| + +first_name: ?string, + |}, +|}; +export type RelayResolverNullableModelClientEdgeTest_WeakModel_Query = {| + response: RelayResolverNullableModelClientEdgeTest_WeakModel_Query$data, + variables: RelayResolverNullableModelClientEdgeTest_WeakModel_Query$variables, +|}; +*/ + +var node/*: ClientRequest*/ = { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": { + "hasClientEdges": true + }, + "name": "RelayResolverNullableModelClientEdgeTest_WeakModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "concreteType": "WeakModel", + "backingField": { + "alias": null, + "args": null, + "fragment": null, + "kind": "RelayResolver", + "name": "edge_to_null_weak_model", + "resolverModule": require('relay-runtime/experimental').weakObjectWrapper(require('./../RelayResolverNullableModelClientEdge-test').edge_to_null_weak_model, '__relay_model_instance', false), + "path": "edge_to_null_weak_model", + "normalizationInfo": { + "concreteType": "WeakModel", + "plural": false, + "normalizationNode": require('./Query__edge_to_null_weak_model$normalization.graphql') + } + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "WeakModel", + "kind": "LinkedField", + "name": "edge_to_null_weak_model", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "fragment": { + "args": null, + "kind": "FragmentSpread", + "name": "WeakModel____relay_model_instance" + }, + "kind": "RelayResolver", + "name": "first_name", + "resolverModule": require('relay-runtime/experimental').resolverDataInjector(require('./WeakModel____relay_model_instance.graphql'), require('./../RelayResolverNullableModelClientEdge-test').first_name, '__relay_model_instance', true), + "path": "edge_to_null_weak_model.first_name" + } + ], + "storageKey": null + } + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "RelayResolverNullableModelClientEdgeTest_WeakModel_Query", + "selections": [ + { + "kind": "ClientEdgeToClientObject", + "backingField": { + "name": "edge_to_null_weak_model", + "args": null, + "fragment": null, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": true + }, + "linkedField": { + "alias": null, + "args": null, + "concreteType": "WeakModel", + "kind": "LinkedField", + "name": "edge_to_null_weak_model", + "plural": false, + "selections": [ + { + "name": "first_name", + "args": null, + "fragment": { + "kind": "InlineFragment", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__relay_model_instance", + "storageKey": null + } + ], + "type": "WeakModel", + "abstractKey": null + }, + "kind": "RelayResolver", + "storageKey": null, + "isOutputType": true + } + ], + "storageKey": null + } + } + ] + }, + "params": { + "cacheID": "a25d6728f75a10c69d1e13cb6be2e84a", + "id": null, + "metadata": {}, + "name": "RelayResolverNullableModelClientEdgeTest_WeakModel_Query", + "operationKind": "query", + "text": null + } +}; + +if (__DEV__) { + (node/*: any*/).hash = "e3560014bc230453c5e68fddb617537e"; +} + +module.exports = ((node/*: any*/)/*: ClientQuery< + RelayResolverNullableModelClientEdgeTest_WeakModel_Query$variables, + RelayResolverNullableModelClientEdgeTest_WeakModel_Query$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/StrongModel____relay_model_instance.graphql.js b/packages/react-relay/__tests__/__generated__/StrongModel____relay_model_instance.graphql.js new file mode 100644 index 0000000000000..f09779b456414 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/StrongModel____relay_model_instance.graphql.js @@ -0,0 +1,68 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<<661159f03895bedac67ce7b08999cb2b>> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { Fragment, ReaderFragment } from 'relay-runtime'; +import type { StrongModel__id$data } from "./StrongModel__id.graphql"; +import type { FragmentType } from "relay-runtime"; +import {StrongModel as strongModelRelayModelInstanceResolverType} from "../RelayResolverNullableModelClientEdge-test.js"; +// Type assertion validating that `strongModelRelayModelInstanceResolverType` resolver is correctly implemented. +// A type error here indicates that the type signature of the resolver module is incorrect. +(strongModelRelayModelInstanceResolverType: ( + id: StrongModel__id$data['id'], +) => mixed); +declare export opaque type StrongModel____relay_model_instance$fragmentType: FragmentType; +export type StrongModel____relay_model_instance$data = {| + +__relay_model_instance: ?ReturnType, + +$fragmentType: StrongModel____relay_model_instance$fragmentType, +|}; +export type StrongModel____relay_model_instance$key = { + +$data?: StrongModel____relay_model_instance$data, + +$fragmentSpreads: StrongModel____relay_model_instance$fragmentType, + ... +}; +*/ + +var node/*: ReaderFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "StrongModel____relay_model_instance", + "selections": [ + { + "alias": null, + "args": null, + "fragment": { + "args": null, + "kind": "FragmentSpread", + "name": "StrongModel__id" + }, + "kind": "RelayResolver", + "name": "__relay_model_instance", + "resolverModule": require('relay-runtime/experimental').resolverDataInjector(require('./StrongModel__id.graphql'), require('./../RelayResolverNullableModelClientEdge-test').StrongModel, 'id', true), + "path": "__relay_model_instance" + } + ], + "type": "StrongModel", + "abstractKey": null +}; + +module.exports = ((node/*: any*/)/*: Fragment< + StrongModel____relay_model_instance$fragmentType, + StrongModel____relay_model_instance$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/StrongModel__id.graphql.js b/packages/react-relay/__tests__/__generated__/StrongModel__id.graphql.js new file mode 100644 index 0000000000000..6b4b5ab2e0943 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/StrongModel__id.graphql.js @@ -0,0 +1,60 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { Fragment, ReaderFragment } from 'relay-runtime'; +import type { FragmentType } from "relay-runtime"; +declare export opaque type StrongModel__id$fragmentType: FragmentType; +export type StrongModel__id$data = {| + +id: string, + +$fragmentType: StrongModel__id$fragmentType, +|}; +export type StrongModel__id$key = { + +$data?: StrongModel__id$data, + +$fragmentSpreads: StrongModel__id$fragmentType, + ... +}; +*/ + +var node/*: ReaderFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "StrongModel__id", + "selections": [ + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ] + } + ], + "type": "StrongModel", + "abstractKey": null +}; + +module.exports = ((node/*: any*/)/*: Fragment< + StrongModel__id$fragmentType, + StrongModel__id$data, +>*/); diff --git a/packages/react-relay/__tests__/__generated__/WeakModel____relay_model_instance.graphql.js b/packages/react-relay/__tests__/__generated__/WeakModel____relay_model_instance.graphql.js new file mode 100644 index 0000000000000..a240584215bb8 --- /dev/null +++ b/packages/react-relay/__tests__/__generated__/WeakModel____relay_model_instance.graphql.js @@ -0,0 +1,61 @@ +/** + * 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. + * + * @oncall relay + * + * @generated SignedSource<> + * @flow + * @lightSyntaxTransform + * @nogrep + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +import type { Fragment, ReaderFragment } from 'relay-runtime'; +import type { WeakModel } from "../RelayResolverNullableModelClientEdge-test.js"; +import type { FragmentType } from "relay-runtime"; +declare export opaque type WeakModel____relay_model_instance$fragmentType: FragmentType; +export type WeakModel____relay_model_instance$data = {| + +__relay_model_instance: WeakModel, + +$fragmentType: WeakModel____relay_model_instance$fragmentType, +|}; +export type WeakModel____relay_model_instance$key = { + +$data?: WeakModel____relay_model_instance$data, + +$fragmentSpreads: WeakModel____relay_model_instance$fragmentType, + ... +}; +*/ + +var node/*: ReaderFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "WeakModel____relay_model_instance", + "selections": [ + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__relay_model_instance", + "storageKey": null + } + ] + } + ], + "type": "WeakModel", + "abstractKey": null +}; + +module.exports = ((node/*: any*/)/*: Fragment< + WeakModel____relay_model_instance$fragmentType, + WeakModel____relay_model_instance$data, +>*/); diff --git a/packages/relay-test-utils/index.js b/packages/relay-test-utils/index.js index 0428dfc5f6fe9..43625e9bf9000 100644 --- a/packages/relay-test-utils/index.js +++ b/packages/relay-test-utils/index.js @@ -17,6 +17,7 @@ const testResolver = require('./RelayResolverTestUtils'); const unwrapContainer = require('./unwrapContainer'); export type {MockResolvers} from './RelayMockPayloadGenerator'; +export type {RelayMockEnvironment} from './RelayModernMockEnvironment'; /** * The public interface to Relay Test Utils.