Skip to content

Commit

Permalink
show failure in execution
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jun 19, 2024
1 parent 002a2ad commit d9c4bd3
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

import { execute, executeSync } from '../execute';
import { print } from '../../language';

Check failure on line 25 in src/execution/__tests__/executor-test.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

'print' is defined but never used. Allowed unused vars must match /^_T/u

Check failure on line 25 in src/execution/__tests__/executor-test.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

It is not allowed to import from directory

describe('Execute: Handles basic execution tasks', () => {
it('throws if no document is provided', () => {
Expand Down Expand Up @@ -72,6 +73,49 @@ describe('Execute: Handles basic execution tasks', () => {
);
});

it('works with deeply nested fragments', async () => {
const DataType: GraphQLObjectType = new GraphQLObjectType({
name: 'Query',
fields: () => ({
a: { type: GraphQLString, resolve: () => 'Apple' },
}),
});


const n = 10000;
const fragments = Array.from(Array(n).keys()).reduce(
(acc, next) =>
acc.concat(`\n
fragment X${next + 1} on Query {
...X${next}
}
`),
'',
);

const document = parse(`
query {
...X${n}
__typename
}
${fragments}
fragment X0 on Query {
a
}
`);

const result = await execute({
schema: new GraphQLSchema({ query: DataType }),
document,
});

expect(result).to.deep.equal({
data: {
a: 'Apple',
},
});
});

it('executes arbitrary code', async () => {
const data = {
a: () => 'Apple',
Expand Down

0 comments on commit d9c4bd3

Please sign in to comment.