Skip to content

Commit

Permalink
Decouple selection benchmark from parser
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jan 22, 2024
1 parent 50560de commit ab7b2a9
Showing 1 changed file with 59 additions and 7 deletions.
66 changes: 59 additions & 7 deletions src/__tests__/selection.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,70 @@ describe('TypedDocument', () => {
...ts.readSourceFolders(['.']),
'simpleSchema.ts': ts.readFileFromRoot('src/__tests__/fixtures/simpleSchema.ts'),
'index.ts': `
import { Kind, OperationTypeNode } from '@0no-co/graphql.web';
import { simpleSchema as schema } from './simpleSchema';
import { parseDocument } from './parser';
import { getDocumentType } from './selection';
import { getVariablesType } from './variables';
type document = parseDocument<\`
query ($org: String!, $repo: String!) {
todos {
id
}
}
\`>;
type document = {
kind: Kind.DOCUMENT;
definitions: [{
kind: Kind.OPERATION_DEFINITION;
operation: OperationTypeNode.QUERY;
name: undefined;
variableDefinitions: [{
kind: Kind.VARIABLE_DEFINITION;
variable: {
kind: Kind.VARIABLE;
name: {
kind: Kind.NAME;
value: 'test';
};
};
type: {
kind: Kind.NON_NULL_TYPE;
type: {
kind: Kind.NAMED_TYPE;
name: {
kind: Kind.NAME;
value: 'String';
};
};
};
defaultValue: undefined;
directives: [];
}];
selectionSet: {
kind: Kind.SELECTION_SET;
selections: [{
kind: Kind.FIELD;
alias: undefined;
name: {
kind: Kind.NAME;
value: 'todos';
};
directives: [];
arguments: [];
selectionSet: {
kind: Kind.SELECTION_SET;
selections: [{
kind: Kind.FIELD;
alias: undefined;
name: {
kind: Kind.NAME;
value: 'id';
};
selectionSet: undefined;
directives: [];
arguments: [];
}];
};
}]
};
directives: [];
}];
};
type Result = getDocumentType<document, schema>;
type Input = getVariablesType<document, schema>;
Expand Down

0 comments on commit ab7b2a9

Please sign in to comment.