Skip to content

Commit

Permalink
Fix result type generic for Error to not double-nest
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D64405588

fbshipit-source-id: 7fbe96cd4b4b7e4a34d46419ebb0e6d4747784d9
  • Loading branch information
itamark authored and facebook-github-bot committed Oct 15, 2024
1 parent af35418 commit 9571d80
Show file tree
Hide file tree
Showing 35 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion compiler/crates/relay-typegen/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ fn make_result_type(typegen_context: &'_ TypegenContext<'_>, value: AST) -> AST

AST::GenericType {
outer: *RESULT_TYPE_NAME,
inner: vec![value, AST::ReadOnlyArray(Box::new(error_type))],
inner: vec![value, error_type],
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { AComedyOfErrors } from "/all/the/worlds/a/stage";
export type FooQuery$variables = {||};
export type FooQuery$data = {|
+me: ?{|
+firstName: Result<?string, $ReadOnlyArray<AComedyOfErrors>>,
+firstName: Result<?string, AComedyOfErrors>,
+lastName: ?string,
|},
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type FooQuery$data = {|
+me: Result<?{|
+firstName: ?string,
+lastName: ?string,
|}, $ReadOnlyArray<mixed>>,
|}, mixed>,
|};
export type FooQuery = {|
response: FooQuery$data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import type { FragmentType, Result } from "relay-runtime";
declare export opaque type AnotherFragment$fragmentType: FragmentType;
export type AnotherFragment$data = {|
+profilePicture: ?{|
+uri: Result<?string, $ReadOnlyArray<mixed>>,
+uri: Result<?string, mixed>,
|},
+$fragmentType: AnotherFragment$fragmentType,
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { AnotherFragment$fragmentType } from "AnotherFragment.graphql";
export type MyQuery$variables = {||};
export type MyQuery$data = {|
+me: ?{|
+id: Result<string, $ReadOnlyArray<mixed>>,
+id: Result<string, mixed>,
+name: ?string,
+$fragmentSpreads: AnotherFragment$fragmentType,
|},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Result } from "relay-runtime";
export type AnotherQuery$variables = {||};
export type AnotherQuery$data = {|
+me: ?{|
+id: Result<string, $ReadOnlyArray<mixed>>,
+id: Result<string, mixed>,
+name: ?string,
|},
|};
Expand All @@ -34,7 +34,7 @@ import type { Result } from "relay-runtime";
export type MyQuery$variables = {||};
export type MyQuery$data = {|
+me: ?{|
+id: Result<string, $ReadOnlyArray<mixed>>,
+id: Result<string, mixed>,
+name: ?string,
+profilePicture: ?{|
+uri: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Result } from "relay-runtime";
export type MyQuery$variables = {||};
export type MyQuery$data = {|
+me: ?{|
+id: Result<string, $ReadOnlyArray<mixed>>,
+id: Result<string, mixed>,
+name: ?string,
|},
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Result } from "relay-runtime";
export type FooQuery$variables = {||};
export type FooQuery$data = {|
+me: ?{|
+firstName: Result<?string, $ReadOnlyArray<mixed>>,
+firstName: Result<?string, mixed>,
+lastName: ?string,
|},
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type MyQuery$data = {|
+me: Result<?{|
+id: string,
+name: ?string,
|}, $ReadOnlyArray<mixed>>,
|}, mixed>,
|};
export type MyQuery = {|
response: MyQuery$data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ClientUser {
import type { FragmentType, Result } from "relay-runtime";
declare export opaque type MyFragment$fragmentType: FragmentType;
export type MyFragment$data = {|
+name: Result<string, $ReadOnlyArray<mixed>>,
+name: Result<string, mixed>,
+$fragmentType: MyFragment$fragmentType,
|};
export type MyFragment$key = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type FooQuery$variables = {||};
export type FooQuery$data = {|
+me: ?{|
+firstName: ?string,
+lastName: Result<?string, $ReadOnlyArray<mixed>>,
+lastName: Result<?string, mixed>,
|},
|};
export type FooQuery = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ClientUser {
import type { FragmentType, Result } from "relay-runtime";
declare export opaque type MyFragment$fragmentType: FragmentType;
export type MyFragment$data = {|
+name: Result<string, $ReadOnlyArray<mixed>>,
+name: Result<string, mixed>,
+$fragmentType: MyFragment$fragmentType,
|};
export type MyFragment$key = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AComedyOfErrors } from "/all/the/worlds/a/stage";
export type FooQuery$variables = Record<PropertyKey, never>;
export type FooQuery$data = {
readonly me: {
readonly firstName: Result<string | null | undefined, ReadonlyArray<AComedyOfErrors>>;
readonly firstName: Result<string | null | undefined, AComedyOfErrors>;
readonly lastName: string | null | undefined;
} | null | undefined;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type FooQuery$data = {
readonly me: Result<{
readonly firstName: string | null | undefined;
readonly lastName: string | null | undefined;
} | null | undefined, ReadonlyArray<unknown>>;
} | null | undefined, unknown>;
};
export type FooQuery = {
response: FooQuery$data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Result } from "relay-runtime";
export type MyQuery$variables = Record<PropertyKey, never>;
export type MyQuery$data = {
readonly me: {
readonly id: Result<string, ReadonlyArray<unknown>>;
readonly id: Result<string, unknown>;
readonly name: string | null | undefined;
} | null | undefined;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type FooQuery$variables = Record<PropertyKey, never>;
export type FooQuery$data = {
readonly me: {
readonly firstName: string | null | undefined;
readonly lastName: Result<string | null | undefined, ReadonlyArray<unknown>>;
readonly lastName: Result<string | null | undefined, unknown>;
} | null | undefined;
};
export type FooQuery = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ClientUser {
==================================== OUTPUT ===================================
import { FragmentRefs, Result } from "relay-runtime";
export type MyFragment$data = {
readonly name: Result<string, ReadonlyArray<unknown>>;
readonly name: Result<string, unknown>;
readonly " $fragmentType": "MyFragment";
};
export type MyFragment$key = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type TestEnums = "mark" | "zuck" | "%future added value";
export type FooQuery$variables = Record<PropertyKey, never>;
export type FooQuery$data = {
readonly me: {
readonly firstName: Result<string | null | undefined, ReadonlyArray<unknown>>;
readonly firstName: Result<string | null | undefined, unknown>;
readonly " $fragmentSpreads": FragmentRefs<"FriendFragment">;
} | null | undefined;
};
Expand All @@ -44,7 +44,7 @@ export type FooQuery = {
export type TestEnums = "mark" | "zuck" | "%future added value";
import { FragmentRefs, Result } from "relay-runtime";
export type FriendFragment$data = {
readonly lastName: Result<string | null | undefined, ReadonlyArray<unknown>>;
readonly lastName: Result<string | null | undefined, unknown>;
readonly name: string | null | undefined;
readonly profilePicture2: {
readonly test_enums: TestEnums | null | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type FooQuery$variables = Record<PropertyKey, never>;
export type FooQuery$data = {
readonly me: {
readonly firstName: string | null | undefined;
readonly lastName: Result<string | null | undefined, ReadonlyArray<unknown>>;
readonly lastName: Result<string | null | undefined, unknown>;
} | null | undefined;
};
export type FooQuery$rawResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type FooQuery$variables = Record<PropertyKey, never>;
export type FooQuery$data = {
readonly me: {
readonly firstName: string | null | undefined;
readonly lastName: Result<string | null | undefined, ReadonlyArray<unknown>>;
readonly lastName: Result<string | null | undefined, unknown>;
} | null | undefined;
};
export type FooQuery = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { FragmentRefs, Result } from "relay-runtime";
export type MyFragment$data = {
readonly my_user: Result<{
readonly name: string | null | undefined;
}, ReadonlyArray<unknown>>;
}, unknown>;
readonly " $fragmentType": "MyFragment";
};
export type MyFragment$key = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extend type Query {
==================================== OUTPUT ===================================
import { FragmentRefs, Result } from "relay-runtime";
export type MyFragment$data = {
readonly my_string: Result<string, ReadonlyArray<unknown>>;
readonly my_string: Result<string, unknown>;
readonly " $fragmentType": "MyFragment";
};
export type MyFragment$key = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ClientUser {
==================================== OUTPUT ===================================
import { FragmentRefs, Result } from "relay-runtime";
export type MyFragment$data = {
readonly name: Result<string, ReadonlyArray<unknown>>;
readonly name: Result<string, unknown>;
readonly " $fragmentType": "MyFragment";
};
export type MyFragment$key = {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9571d80

Please sign in to comment.