Skip to content

Commit

Permalink
extract graph, types
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed May 27, 2024
1 parent 3a14f7e commit 3d0b369
Show file tree
Hide file tree
Showing 13 changed files with 929 additions and 791 deletions.
411 changes: 411 additions & 0 deletions src/execution/Graph.ts

Large diffs are not rendered by default.

845 changes: 142 additions & 703 deletions src/execution/IncrementalPublisher.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/execution/__tests__/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { execute, experimentalExecuteIncrementally } from '../execute.js';
import type {
InitialIncrementalExecutionResult,
SubsequentIncrementalExecutionResult,
} from '../IncrementalPublisher.js';
} from '../types.js';

const friendType = new GraphQLObjectType({
fields: {
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/lists-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { GraphQLSchema } from '../../type/schema.js';
import { buildSchema } from '../../utilities/buildASTSchema.js';

import { execute, executeSync } from '../execute.js';
import type { ExecutionResult } from '../IncrementalPublisher.js';
import type { ExecutionResult } from '../types.js';

describe('Execute: Accepts any iterable as list value', () => {
function complete(rootValue: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/nonnull-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { GraphQLSchema } from '../../type/schema.js';
import { buildSchema } from '../../utilities/buildASTSchema.js';

import { execute, executeSync } from '../execute.js';
import type { ExecutionResult } from '../IncrementalPublisher.js';
import type { ExecutionResult } from '../types.js';

const syncError = new Error('sync');
const syncNonNullError = new Error('syncNonNull');
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/oneof-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { parse } from '../../language/parser.js';
import { buildSchema } from '../../utilities/buildASTSchema.js';

import { execute } from '../execute.js';
import type { ExecutionResult } from '../IncrementalPublisher.js';
import type { ExecutionResult } from '../types.js';

const schema = buildSchema(`
type Query {
Expand Down
51 changes: 24 additions & 27 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { experimentalExecuteIncrementally } from '../execute.js';
import type {
InitialIncrementalExecutionResult,
SubsequentIncrementalExecutionResult,
} from '../IncrementalPublisher.js';
} from '../types.js';

const friendType = new GraphQLObjectType({
fields: {
Expand Down Expand Up @@ -635,7 +635,7 @@ describe('Execute: stream directive', () => {
}
}
`);
const result = await completeAsync(document, 2, {
const result = await completeAsync(document, 3, {
async *friendList() {
yield await Promise.resolve(friends[0]);
yield await Promise.resolve(friends[1]);
Expand Down Expand Up @@ -665,6 +665,12 @@ describe('Execute: stream directive', () => {
id: '0',
},
],
hasNext: true,
},
},
{
done: false,
value: {
completed: [{ id: '0' }],
hasNext: false,
},
Expand Down Expand Up @@ -1367,10 +1373,6 @@ describe('Execute: stream directive', () => {
},
{
incremental: [
{
items: [{ name: 'Luke' }],
id: '1',
},
{
data: { scalarField: null },
id: '0',
Expand All @@ -1382,8 +1384,12 @@ describe('Execute: stream directive', () => {
},
],
},
{
items: [{ name: 'Luke' }],
id: '1',
},
],
completed: [{ id: '1' }, { id: '0' }],
completed: [{ id: '0' }, { id: '1' }],
hasNext: false,
},
]);
Expand Down Expand Up @@ -1818,14 +1824,14 @@ describe('Execute: stream directive', () => {
value: {
pending: [{ id: '2', path: ['friendList', 1], label: 'DeferName' }],
incremental: [
{
items: [{ id: '2' }],
id: '1',
},
{
data: { name: 'Luke' },
id: '0',
},
{
items: [{ id: '2' }],
id: '1',
},
],
completed: [{ id: '0' }],
hasNext: true,
Expand Down Expand Up @@ -1921,14 +1927,14 @@ describe('Execute: stream directive', () => {
value: {
pending: [{ id: '2', path: ['friendList', 1], label: 'DeferName' }],
incremental: [
{
items: [{ id: '2' }],
id: '1',
},
{
data: { name: 'Luke' },
id: '0',
},
{
items: [{ id: '2' }],
id: '1',
},
],
completed: [{ id: '0' }],
hasNext: true,
Expand All @@ -1940,30 +1946,21 @@ describe('Execute: stream directive', () => {
resolveIterableCompletion(null);
const result3 = await result3Promise;
expectJSON(result3).toDeepEqual({
value: {
completed: [{ id: '1' }],
hasNext: true,
},
done: false,
});

const result4 = await iterator.next();
expectJSON(result4).toDeepEqual({
value: {
incremental: [
{
data: { name: 'Han' },
id: '2',
},
],
completed: [{ id: '2' }],
completed: [{ id: '1' }, { id: '2' }],
hasNext: false,
},
done: false,
});

const result5 = await iterator.next();
expectJSON(result5).toDeepEqual({
const result4 = await iterator.next();
expectJSON(result4).toDeepEqual({
value: undefined,
done: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/subscribe-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GraphQLSchema } from '../../type/schema.js';

import type { ExecutionArgs } from '../execute.js';
import { createSourceEventStream, subscribe } from '../execute.js';
import type { ExecutionResult } from '../IncrementalPublisher.js';
import type { ExecutionResult } from '../types.js';

import { SimplePubSub } from './simplePubSub.js';

Expand Down
Loading

0 comments on commit 3d0b369

Please sign in to comment.