Skip to content

Commit

Permalink
incremental delivery without branching
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Mar 27, 2023
1 parent 505d096 commit 98584b4
Show file tree
Hide file tree
Showing 13 changed files with 3,001 additions and 989 deletions.
1,104 changes: 1,015 additions & 89 deletions src/execution/__tests__/defer-test.ts

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { expectJSON } from '../../__testUtils__/expectJSON.js';
import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';

import { inspect } from '../../jsutils/inspect.js';
import type { Path } from '../../jsutils/Path.js';

import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';

import type { GraphQLResolveInfo } from '../../type/definition.js';
import {
GraphQLInterfaceType,
GraphQLList,
Expand Down Expand Up @@ -191,7 +193,7 @@ describe('Execute: Handles basic execution tasks', () => {
});

it('provides info about current execution state', () => {
let resolvedInfo;
let resolvedInfo: GraphQLResolveInfo | undefined;
const testType = new GraphQLObjectType({
name: 'Test',
fields: {
Expand Down Expand Up @@ -239,13 +241,22 @@ describe('Execute: Handles basic execution tasks', () => {
const field = operation.selectionSet.selections[0];
expect(resolvedInfo).to.deep.include({
fieldNodes: [field],
path: { prev: undefined, key: 'result', typename: 'Test' },
variableValues: { var: 'abc' },
});

expect(resolvedInfo?.path).to.deep.include({
prev: undefined,
key: 'result',
});

expect(resolvedInfo?.path.info).to.deep.include({
parentType: testType,
fieldName: 'test',
});
});

it('populates path correctly with complex types', () => {
let path;
let path: Path<unknown> | undefined;
const someObject = new GraphQLObjectType({
name: 'SomeObject',
fields: {
Expand Down Expand Up @@ -288,18 +299,27 @@ describe('Execute: Handles basic execution tasks', () => {

executeSync({ schema, document, rootValue });

expect(path).to.deep.equal({
expect(path).to.deep.include({
key: 'l2',
typename: 'SomeObject',
prev: {
key: 0,
typename: undefined,
prev: {
key: 'l1',
typename: 'SomeQuery',
prev: undefined,
},
},
});

expect(path?.info).to.deep.include({
parentType: someObject,
fieldName: 'test',
});

expect(path?.prev).to.deep.include({
key: 0,
info: undefined,
});

expect(path?.prev?.prev).to.deep.include({
key: 'l1',
});

expect(path?.prev?.prev?.info).to.deep.include({
parentType: testType,
fieldName: 'test',
});
});

Expand Down

0 comments on commit 98584b4

Please sign in to comment.