-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, we tried to split the packages similarly to how Relay does it internally. However, we never finished this effort leaving it fragmented. I'd like to propose merging it back together with these steps to follow: - cleanup the package (remove things we don't need to wrap because Relay already provides the necessary Flow types) - get it ready for next major version Relay 11 adeira-source-id: 10aba4b8307e7ca9ee757885054c752e4bc8d201
- Loading branch information
1 parent
29ceaf8
commit a8bad2a
Showing
43 changed files
with
824 additions
and
167 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// @flow strict | ||
|
||
// https://github.com/facebook/relay/blob/master/packages/relay-runtime/network/RelayNetworkTypes.js | ||
|
||
export type PayloadData = { [key: string]: mixed, ... }; | ||
|
||
export type PayloadError = { | ||
message: string, | ||
locations?: Array<{ | ||
line: number, | ||
column: number, | ||
... | ||
}>, | ||
// Not officially part of the spec, but used at Facebook | ||
severity?: 'CRITICAL' | 'ERROR' | 'WARNING', | ||
... | ||
}; | ||
|
||
export type PayloadExtensions = { [key: string]: mixed, ... }; | ||
|
||
/** | ||
* The shape of a GraphQL response as dictated by the | ||
* [spec](https://graphql.github.io/graphql-spec/June2018/#sec-Response-Format) | ||
*/ | ||
export type GraphQLResponseWithData = {| | ||
+data: PayloadData, | ||
+errors?: Array<PayloadError>, | ||
+extensions?: PayloadExtensions, | ||
+label?: string, | ||
+path?: Array<string | number>, | ||
|}; | ||
|
||
export type GraphQLResponseWithoutData = {| | ||
+data?: ?PayloadData, | ||
+errors: Array<PayloadError>, | ||
+extensions?: PayloadExtensions, | ||
+label?: string, | ||
+path?: Array<string | number>, | ||
|}; | ||
|
||
export type GraphQLResponseWithExtensionsOnly = {| | ||
// Per https://spec.graphql.org/June2018/#sec-Errors | ||
// > If the data entry in the response is not present, the errors entry | ||
// > in the response must not be empty. It must contain at least one error | ||
// This means a payload has to have either a data key or an errors key: | ||
// but the spec leaves room for the combination of data: null plus extensions | ||
// since `data: null` is a *required* output if there was an error during | ||
// execution, but the inverse is not described in the sepc: `data: null` | ||
// does not necessarily indicate that there was an error. | ||
+data: null, | ||
+extensions: PayloadExtensions, | ||
|}; | ||
|
||
export type GraphQLSingularResponse = | ||
| GraphQLResponseWithData | ||
| GraphQLResponseWithExtensionsOnly | ||
| GraphQLResponseWithoutData; | ||
|
||
export type GraphQLResponse = GraphQLSingularResponse | $ReadOnlyArray<GraphQLSingularResponse>; |
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,53 @@ | ||
// @flow strict-local | ||
|
||
import type { Variables } from 'relay-runtime'; | ||
// https://github.com/facebook/relay/blob/master/packages/relay-runtime/util/RelayRuntimeTypes.js | ||
|
||
export type DataID = string; | ||
|
||
export type RecordProxy = $ReadOnly<{| | ||
copyFieldsFrom: (sourceRecord: RecordProxy) => void, | ||
getDataID: () => string, | ||
getLinkedRecord: (name: string, args?: ?Variables) => ?RecordProxy, | ||
getLinkedRecords: (name: string, args?: ?Variables) => ?$ReadOnlyArray<?RecordProxy>, | ||
getOrCreateLinkedRecord: (name: string, typeName: string, args?: ?Variables) => RecordProxy, | ||
getType: () => string, | ||
getValue: (name: string, args?: ?Variables) => mixed, | ||
setLinkedRecord: (record: RecordProxy, name: string, args?: ?Variables) => RecordProxy, | ||
setLinkedRecords: ( | ||
records: $ReadOnlyArray<?RecordProxy>, | ||
name: string, | ||
args?: ?Variables, | ||
) => RecordProxy, | ||
setValue: (value: mixed, name: string, args?: ?Variables) => RecordProxy, | ||
|}>; | ||
|
||
export interface RecordSourceProxy { | ||
create(dataID: DataID, typeName: string): RecordProxy; | ||
delete(dataID: DataID): void; | ||
get(dataID: DataID): ?RecordProxy; | ||
getRoot(): RecordProxy; | ||
invalidateStore(): void; | ||
} | ||
|
||
export interface ReadOnlyRecordProxy { | ||
getDataID(): DataID; | ||
getLinkedRecord(name: string, args?: ?Variables): ?RecordProxy; | ||
getLinkedRecords(name: string, args?: ?Variables): ?Array<?RecordProxy>; | ||
getType(): string; | ||
getValue(name: string, args?: ?Variables): mixed; | ||
} | ||
|
||
export type HandleFieldPayload = {| | ||
// The arguments that were fetched. | ||
+args: Variables, | ||
// The __id of the record containing the source/handle field. | ||
+dataID: DataID, | ||
// The (storage) key at which the original server data was written. | ||
+fieldKey: string, | ||
// The name of the handle. | ||
+handle: string, | ||
// The (storage) key at which the handle's data should be written by the | ||
// handler. | ||
+handleKey: string, | ||
|}; |
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
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
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
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,36 @@ | ||
// @flow | ||
|
||
import * as publicExports from '../index'; | ||
|
||
it('exports only what we want to export', () => { | ||
// this is to make sure we are always exporting the subset we want to | ||
expect(Object.keys(publicExports)).toMatchInlineSnapshot(` | ||
Array [ | ||
"FetchResponseError", | ||
"FetchTimeoutError", | ||
"createEnvironment", | ||
"createLocalEnvironment", | ||
"createNetworkFetcher", | ||
"getDataFromRequest", | ||
"RelayDebugLogger", | ||
"RelayEagerLogger", | ||
"RelayLazyLogger", | ||
"commitLocalUpdate", | ||
"commitMutation", | ||
"commitMutationAsync", | ||
"createFragmentContainer", | ||
"createPaginationContainer", | ||
"createRefetchContainer", | ||
"fetchQuery", | ||
"LocalQueryRenderer", | ||
"QueryRenderer", | ||
"requestSubscription", | ||
"graphql", | ||
"readInlineData", | ||
"ConnectionHandler", | ||
"RelayEnvironmentProvider", | ||
"useMutation", | ||
"useRelayEnvironment", | ||
] | ||
`); | ||
}); |
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
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
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.