-
Notifications
You must be signed in to change notification settings - Fork 30.5k
[relay-runtime] Export readFragment from index and resolverDataInjector from experimental #74036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alina-zaieva
wants to merge
5
commits into
DefinitelyTyped:master
Choose a base branch
from
alina-zaieva:add-readfragment-and-resolverdatainjector-to-relay-runtime
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−17
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2036124
Update typings to expose readFragment from index and resolverDataInje…
alina-zaieva 07ad1e6
Format modified files
alina-zaieva aac2b8b
Format tests
alina-zaieva 37340f5
Remove type from the comment
alina-zaieva 80daff6
Handle error type correctly in results
alina-zaieva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,27 @@ | ||
| import { DataID } from "./lib/util/RelayRuntimeTypes"; | ||
|
|
||
| export { resolverDataInjector } from "./lib/store/live-resolvers/resolverDataInjector"; | ||
| export { observeFragment } from "./lib/store/observeFragmentExperimental"; | ||
| export { observeQuery } from "./lib/store/observeQueryExperimental"; | ||
| export { waitForFragmentData } from "./lib/store/waitForFragmentExperimental"; | ||
|
|
||
| export type IdOf<_A extends string, Typename extends undefined | string = undefined> = Typename extends undefined | ||
| ? { id: DataID } | ||
| : { id: DataID; __typename: Typename }; | ||
|
|
||
| interface ErrorResult<E> { | ||
| ok: false; | ||
| errors: readonly E[]; | ||
| } | ||
|
|
||
| interface OkayResult<T> { | ||
| ok: true; | ||
| value: T; | ||
| } | ||
|
|
||
| // The type returned by fields annotated with `@catch` | ||
| export type Result<T, E> = OkayResult<T> | ErrorResult<E>; | ||
|
|
||
| export function isValueResult<T = unknown>(input: Result<T, unknown>): input is OkayResult<T>; | ||
|
|
||
| export function isErrorResult<E = unknown>(input: Result<unknown, E>): input is ErrorResult<E>; | ||
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
types/relay-runtime/lib/store/live-resolvers/resolverDataInjector.d.ts
This file contains hidden or 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,20 @@ | ||
| import type { GraphQLTaggedNode } from "../../query/RelayModernGraphQLTag"; | ||
| import type { FragmentType } from "../RelayStoreTypes"; | ||
|
|
||
| /** | ||
| * This a higher order function that returns a relay resolver that can read the data for | ||
| * the fragment`. | ||
| * | ||
| * - fragment: contains fragment Reader AST with resolver's data dependencies. | ||
| * - resolverFn: original resolver function that expects a data from the fragment | ||
| * - (optional) fieldName: individual field that needs to be read out of the fragment. | ||
| * | ||
| * This will not call the `resolverFn` if the fragment data for it is null/undefined. | ||
| * The compiler generates calls to this function, ensuring the correct set of arguments. | ||
| */ | ||
| export function resolverDataInjector( | ||
| fragment: GraphQLTaggedNode, | ||
| _resolverFn: unknown, | ||
| fieldName?: string, | ||
| isRequiredField?: boolean, | ||
| ): (fragmentKey: FragmentType, args: unknown) => unknown; |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.