-
Notifications
You must be signed in to change notification settings - Fork 472
Closed
Labels
future 🔮An enhancement or feature proposal that will be addressed after the next releaseAn enhancement or feature proposal that will be addressed after the next release
Description
This RFC supersedes #2995.
Summary
See spec edits for incremental delivery support in graphql-spec
: https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ec
See updated implementation of graphql-js: graphql/graphql-js#3659
Previously, our current definition of ExecutionResult
looks like the following:
urql/packages/core/src/types.ts
Lines 21 to 37 in 9ecfba4
export type ExecutionResult = | |
| { | |
errors?: | |
| Array<Partial<GraphQLError> | string | Error> | |
| readonly GraphQLError[]; | |
data?: null | Record<string, any>; | |
extensions?: Record<string, any>; | |
hasNext?: boolean; | |
} | |
| { | |
errors?: | |
| Array<Partial<GraphQLError> | string | Error> | |
| readonly GraphQLError[]; | |
data: any; | |
path: (string | number)[]; | |
hasNext?: boolean; | |
}; |
export type ExecutionResult =
| {
errors?:
| Array<Partial<GraphQLError> | string | Error>
| readonly GraphQLError[];
data?: null | Record<string, any>;
extensions?: Record<string, any>;
hasNext?: boolean;
}
| {
errors?:
| Array<Partial<GraphQLError> | string | Error>
| readonly GraphQLError[];
data: any;
path: (string | number)[];
hasNext?: boolean;
};
The spec has been updated to instead look like the following for incremental responses:
interface BaseExecutionResult {
errors?:
| Array<Partial<GraphQLError> | string | Error>
| readonly GraphQLError[];
extensions?: Record<string, any>;
}
interface BaseIncrementalDeliveryResult {
label?: string;
path: (string | number)[];
}
interface DeferResult extends BaseIncrementalDeliveryResult {
data: unknown | null
}
interface StreamResult extends BaseIncrementalDeliveryResult {
items: unknown[] | null
}
type IncrementalResult = DeferResult | StreamResult;
export interface ExecutionResult extends BaseExecutionResult {
incremental?: IncrementalDeliveryResult[];
data?: null | Record<string, any>;
hasNext?: boolean;
}
Proposed Solution
- Update
@urql/core
with above types (with modifications?)- We probably don't want to support the old format, since it was experimental. Instead, I'd flag this as a
minor
with a note in the changelog that reflects why we've done this.
- We probably don't want to support the old format, since it was experimental. Instead, I'd flag this as a
- Update
mergeResultPatch
to reflect the new format:urql/packages/core/src/utils/result.ts
Lines 28 to 32 in 9ecfba4
export const mergeResultPatch = ( prevResult: OperationResult, patch: ExecutionResult, response?: any ): OperationResult => {
Requirements
- We must be able to comply with the new format in full; again,
label
is treated as optional and we don't currently use its information - We should look into how
extensions
anderrors
are now treated, since there could be multiple ones sent per response. - We should check what happens to
result.extensions
andresult.errors
if those can also be present onresult.incremental[].extensions
andresult.incremental[].errors
now
Metadata
Metadata
Assignees
Labels
future 🔮An enhancement or feature proposal that will be addressed after the next releaseAn enhancement or feature proposal that will be addressed after the next release