Skip to content
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

introduce transformer from latest incremental format to legacy format #4319

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
639 changes: 639 additions & 0 deletions src/transform/__tests__/abstract-test.ts

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions src/transform/__tests__/buildTransformationContext-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { invariant } from '../../jsutils/invariant.js';

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

import { GraphQLObjectType } from '../../type/definition.js';
import { GraphQLString } from '../../type/scalars.js';
import { GraphQLSchema } from '../../type/schema.js';

import { validateExecutionArgs } from '../../execution/execute.js';

import { buildTransformationContext } from '../buildTransformationContext.js';

const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: { someField: { type: GraphQLString } },
}),
});

describe('buildTransformationContext', () => {
it('should build a transformation context', () => {
const validatedExecutionArgs = validateExecutionArgs({
schema,
document: parse('{ someField }'),
});

invariant('schema' in validatedExecutionArgs);

const context = buildTransformationContext(
validatedExecutionArgs,
'__prefix__',
);

expect(context.originalDeferLabels instanceof Map).to.equal(true);
expect(context.originalStreamLabels instanceof Map).to.equal(true);
expect(context.deferredGroupedFieldSets instanceof Map).to.equal(true);
expect(context.streams instanceof Map).to.equal(true);
expect(context.prefix).to.equal('__prefix__');
expect(context.pendingLabelsByPath instanceof Map).to.equal(true);
expect(context.pendingResultsById instanceof Map).to.equal(true);
expect(context.mergedResult).to.deep.equal({});
});

it('should handle non-standard directives', () => {
const validatedExecutionArgs = validateExecutionArgs({
schema,
document: parse('{ ... @someDirective { someField } }'),
});

invariant('schema' in validatedExecutionArgs);

expect(() =>
buildTransformationContext(validatedExecutionArgs, '__prefix__'),
).not.to.throw();
});
});
Loading
Loading