webpipe-js 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +118 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.mjs +115 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,8 +36,11 @@ __export(index_exports, {
|
|
|
36
36
|
printCondition: () => printCondition,
|
|
37
37
|
printConfig: () => printConfig,
|
|
38
38
|
printDescribe: () => printDescribe,
|
|
39
|
+
printGraphQLSchema: () => printGraphQLSchema,
|
|
39
40
|
printMock: () => printMock,
|
|
41
|
+
printMutationResolver: () => printMutationResolver,
|
|
40
42
|
printPipeline: () => printPipeline,
|
|
43
|
+
printQueryResolver: () => printQueryResolver,
|
|
41
44
|
printRoute: () => printRoute,
|
|
42
45
|
printTest: () => printTest,
|
|
43
46
|
printVariable: () => printVariable
|
|
@@ -137,6 +140,9 @@ var Parser = class {
|
|
|
137
140
|
const routes = [];
|
|
138
141
|
const describes = [];
|
|
139
142
|
const comments = [];
|
|
143
|
+
let graphqlSchema;
|
|
144
|
+
const queries = [];
|
|
145
|
+
const mutations = [];
|
|
140
146
|
while (!this.eof()) {
|
|
141
147
|
this.skipWhitespaceOnly();
|
|
142
148
|
if (this.eof()) break;
|
|
@@ -153,6 +159,24 @@ var Parser = class {
|
|
|
153
159
|
configs.push(cfg);
|
|
154
160
|
continue;
|
|
155
161
|
}
|
|
162
|
+
const schema = this.tryParse(() => this.parseGraphQLSchema());
|
|
163
|
+
if (schema) {
|
|
164
|
+
schema.lineNumber = this.getLineNumber(start);
|
|
165
|
+
graphqlSchema = schema;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const query = this.tryParse(() => this.parseQueryResolver());
|
|
169
|
+
if (query) {
|
|
170
|
+
query.lineNumber = this.getLineNumber(start);
|
|
171
|
+
queries.push(query);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const mutation = this.tryParse(() => this.parseMutationResolver());
|
|
175
|
+
if (mutation) {
|
|
176
|
+
mutation.lineNumber = this.getLineNumber(start);
|
|
177
|
+
mutations.push(mutation);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
156
180
|
const namedPipe = this.tryParse(() => this.parseNamedPipeline());
|
|
157
181
|
if (namedPipe) {
|
|
158
182
|
namedPipe.lineNumber = this.getLineNumber(start);
|
|
@@ -192,7 +216,7 @@ var Parser = class {
|
|
|
192
216
|
const start = Math.max(0, idx);
|
|
193
217
|
this.report("Unclosed backtick-delimited string", start, start + 1, "warning");
|
|
194
218
|
}
|
|
195
|
-
return { configs, pipelines, variables, routes, describes, comments };
|
|
219
|
+
return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations };
|
|
196
220
|
}
|
|
197
221
|
eof() {
|
|
198
222
|
return this.pos >= this.len;
|
|
@@ -538,6 +562,42 @@ var Parser = class {
|
|
|
538
562
|
this.skipWhitespaceOnly();
|
|
539
563
|
return { varType, name, value, inlineComment: inlineComment || void 0 };
|
|
540
564
|
}
|
|
565
|
+
parseGraphQLSchema() {
|
|
566
|
+
this.expect("graphql");
|
|
567
|
+
this.skipInlineSpaces();
|
|
568
|
+
this.expect("schema");
|
|
569
|
+
this.skipInlineSpaces();
|
|
570
|
+
this.expect("=");
|
|
571
|
+
const inlineComment = this.parseInlineComment();
|
|
572
|
+
this.skipInlineSpaces();
|
|
573
|
+
const sdl = this.parseBacktickString();
|
|
574
|
+
this.skipWhitespaceOnly();
|
|
575
|
+
return { sdl, inlineComment: inlineComment || void 0 };
|
|
576
|
+
}
|
|
577
|
+
parseQueryResolver() {
|
|
578
|
+
this.expect("query");
|
|
579
|
+
this.skipInlineSpaces();
|
|
580
|
+
const name = this.parseIdentifier();
|
|
581
|
+
this.skipInlineSpaces();
|
|
582
|
+
this.expect("=");
|
|
583
|
+
const inlineComment = this.parseInlineComment();
|
|
584
|
+
this.skipWhitespaceOnly();
|
|
585
|
+
const pipeline = this.parsePipeline();
|
|
586
|
+
this.skipWhitespaceOnly();
|
|
587
|
+
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
588
|
+
}
|
|
589
|
+
parseMutationResolver() {
|
|
590
|
+
this.expect("mutation");
|
|
591
|
+
this.skipInlineSpaces();
|
|
592
|
+
const name = this.parseIdentifier();
|
|
593
|
+
this.skipInlineSpaces();
|
|
594
|
+
this.expect("=");
|
|
595
|
+
const inlineComment = this.parseInlineComment();
|
|
596
|
+
this.skipWhitespaceOnly();
|
|
597
|
+
const pipeline = this.parsePipeline();
|
|
598
|
+
this.skipWhitespaceOnly();
|
|
599
|
+
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
600
|
+
}
|
|
541
601
|
parseRoute() {
|
|
542
602
|
const method = this.parseMethod();
|
|
543
603
|
this.skipInlineSpaces();
|
|
@@ -762,6 +822,39 @@ function printVariable(variable) {
|
|
|
762
822
|
}
|
|
763
823
|
return variableLine;
|
|
764
824
|
}
|
|
825
|
+
function printGraphQLSchema(schema) {
|
|
826
|
+
const schemaLine = `graphql schema = \`${schema.sdl}\``;
|
|
827
|
+
if (schema.inlineComment) {
|
|
828
|
+
return `${schemaLine} ${printComment(schema.inlineComment)}`;
|
|
829
|
+
}
|
|
830
|
+
return schemaLine;
|
|
831
|
+
}
|
|
832
|
+
function printQueryResolver(query) {
|
|
833
|
+
const lines = [];
|
|
834
|
+
const queryLine = `query ${query.name} =`;
|
|
835
|
+
if (query.inlineComment) {
|
|
836
|
+
lines.push(`${queryLine} ${printComment(query.inlineComment)}`);
|
|
837
|
+
} else {
|
|
838
|
+
lines.push(queryLine);
|
|
839
|
+
}
|
|
840
|
+
query.pipeline.steps.forEach((step) => {
|
|
841
|
+
lines.push(formatPipelineStep(step));
|
|
842
|
+
});
|
|
843
|
+
return lines.join("\n");
|
|
844
|
+
}
|
|
845
|
+
function printMutationResolver(mutation) {
|
|
846
|
+
const lines = [];
|
|
847
|
+
const mutationLine = `mutation ${mutation.name} =`;
|
|
848
|
+
if (mutation.inlineComment) {
|
|
849
|
+
lines.push(`${mutationLine} ${printComment(mutation.inlineComment)}`);
|
|
850
|
+
} else {
|
|
851
|
+
lines.push(mutationLine);
|
|
852
|
+
}
|
|
853
|
+
mutation.pipeline.steps.forEach((step) => {
|
|
854
|
+
lines.push(formatPipelineStep(step));
|
|
855
|
+
});
|
|
856
|
+
return lines.join("\n");
|
|
857
|
+
}
|
|
765
858
|
function printMock(mock, indent = " ") {
|
|
766
859
|
return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
|
|
767
860
|
}
|
|
@@ -821,6 +914,15 @@ function prettyPrint(program) {
|
|
|
821
914
|
program.configs.forEach((config) => {
|
|
822
915
|
allItems.push({ type: "config", item: config, lineNumber: config.lineNumber || 0 });
|
|
823
916
|
});
|
|
917
|
+
if (program.graphqlSchema) {
|
|
918
|
+
allItems.push({ type: "graphqlSchema", item: program.graphqlSchema, lineNumber: program.graphqlSchema.lineNumber || 0 });
|
|
919
|
+
}
|
|
920
|
+
program.queries.forEach((query) => {
|
|
921
|
+
allItems.push({ type: "query", item: query, lineNumber: query.lineNumber || 0 });
|
|
922
|
+
});
|
|
923
|
+
program.mutations.forEach((mutation) => {
|
|
924
|
+
allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
|
|
925
|
+
});
|
|
824
926
|
program.routes.forEach((route) => {
|
|
825
927
|
allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
|
|
826
928
|
});
|
|
@@ -846,6 +948,18 @@ function prettyPrint(program) {
|
|
|
846
948
|
lines.push(printConfig(entry.item));
|
|
847
949
|
lines.push("");
|
|
848
950
|
break;
|
|
951
|
+
case "graphqlSchema":
|
|
952
|
+
lines.push(printGraphQLSchema(entry.item));
|
|
953
|
+
lines.push("");
|
|
954
|
+
break;
|
|
955
|
+
case "query":
|
|
956
|
+
lines.push(printQueryResolver(entry.item));
|
|
957
|
+
lines.push("");
|
|
958
|
+
break;
|
|
959
|
+
case "mutation":
|
|
960
|
+
lines.push(printMutationResolver(entry.item));
|
|
961
|
+
lines.push("");
|
|
962
|
+
break;
|
|
849
963
|
case "route":
|
|
850
964
|
lines.push(printRoute(entry.item));
|
|
851
965
|
lines.push("");
|
|
@@ -953,8 +1067,11 @@ function formatWhen(when) {
|
|
|
953
1067
|
printCondition,
|
|
954
1068
|
printConfig,
|
|
955
1069
|
printDescribe,
|
|
1070
|
+
printGraphQLSchema,
|
|
956
1071
|
printMock,
|
|
1072
|
+
printMutationResolver,
|
|
957
1073
|
printPipeline,
|
|
1074
|
+
printQueryResolver,
|
|
958
1075
|
printRoute,
|
|
959
1076
|
printTest,
|
|
960
1077
|
printVariable
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,9 @@ interface Program {
|
|
|
5
5
|
routes: Route[];
|
|
6
6
|
describes: Describe[];
|
|
7
7
|
comments: Comment[];
|
|
8
|
+
graphqlSchema?: GraphQLSchema;
|
|
9
|
+
queries: QueryResolver[];
|
|
10
|
+
mutations: MutationResolver[];
|
|
8
11
|
}
|
|
9
12
|
interface Comment {
|
|
10
13
|
type: 'standalone' | 'inline';
|
|
@@ -49,6 +52,23 @@ interface Variable {
|
|
|
49
52
|
lineNumber?: number;
|
|
50
53
|
inlineComment?: Comment;
|
|
51
54
|
}
|
|
55
|
+
interface GraphQLSchema {
|
|
56
|
+
sdl: string;
|
|
57
|
+
lineNumber?: number;
|
|
58
|
+
inlineComment?: Comment;
|
|
59
|
+
}
|
|
60
|
+
interface QueryResolver {
|
|
61
|
+
name: string;
|
|
62
|
+
pipeline: Pipeline;
|
|
63
|
+
lineNumber?: number;
|
|
64
|
+
inlineComment?: Comment;
|
|
65
|
+
}
|
|
66
|
+
interface MutationResolver {
|
|
67
|
+
name: string;
|
|
68
|
+
pipeline: Pipeline;
|
|
69
|
+
lineNumber?: number;
|
|
70
|
+
inlineComment?: Comment;
|
|
71
|
+
}
|
|
52
72
|
interface Route {
|
|
53
73
|
method: string;
|
|
54
74
|
path: string;
|
|
@@ -156,6 +176,9 @@ declare function printRoute(route: Route): string;
|
|
|
156
176
|
declare function printConfig(config: Config): string;
|
|
157
177
|
declare function printPipeline(pipeline: NamedPipeline): string;
|
|
158
178
|
declare function printVariable(variable: Variable): string;
|
|
179
|
+
declare function printGraphQLSchema(schema: GraphQLSchema): string;
|
|
180
|
+
declare function printQueryResolver(query: QueryResolver): string;
|
|
181
|
+
declare function printMutationResolver(mutation: MutationResolver): string;
|
|
159
182
|
declare function printMock(mock: Mock, indent?: string): string;
|
|
160
183
|
declare function printCondition(condition: Condition, indent?: string): string;
|
|
161
184
|
declare function printTest(test: It): string;
|
|
@@ -170,4 +193,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
170
193
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
171
194
|
declare function formatWhen(when: When): string;
|
|
172
195
|
|
|
173
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
|
196
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type GraphQLSchema, type It, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ interface Program {
|
|
|
5
5
|
routes: Route[];
|
|
6
6
|
describes: Describe[];
|
|
7
7
|
comments: Comment[];
|
|
8
|
+
graphqlSchema?: GraphQLSchema;
|
|
9
|
+
queries: QueryResolver[];
|
|
10
|
+
mutations: MutationResolver[];
|
|
8
11
|
}
|
|
9
12
|
interface Comment {
|
|
10
13
|
type: 'standalone' | 'inline';
|
|
@@ -49,6 +52,23 @@ interface Variable {
|
|
|
49
52
|
lineNumber?: number;
|
|
50
53
|
inlineComment?: Comment;
|
|
51
54
|
}
|
|
55
|
+
interface GraphQLSchema {
|
|
56
|
+
sdl: string;
|
|
57
|
+
lineNumber?: number;
|
|
58
|
+
inlineComment?: Comment;
|
|
59
|
+
}
|
|
60
|
+
interface QueryResolver {
|
|
61
|
+
name: string;
|
|
62
|
+
pipeline: Pipeline;
|
|
63
|
+
lineNumber?: number;
|
|
64
|
+
inlineComment?: Comment;
|
|
65
|
+
}
|
|
66
|
+
interface MutationResolver {
|
|
67
|
+
name: string;
|
|
68
|
+
pipeline: Pipeline;
|
|
69
|
+
lineNumber?: number;
|
|
70
|
+
inlineComment?: Comment;
|
|
71
|
+
}
|
|
52
72
|
interface Route {
|
|
53
73
|
method: string;
|
|
54
74
|
path: string;
|
|
@@ -156,6 +176,9 @@ declare function printRoute(route: Route): string;
|
|
|
156
176
|
declare function printConfig(config: Config): string;
|
|
157
177
|
declare function printPipeline(pipeline: NamedPipeline): string;
|
|
158
178
|
declare function printVariable(variable: Variable): string;
|
|
179
|
+
declare function printGraphQLSchema(schema: GraphQLSchema): string;
|
|
180
|
+
declare function printQueryResolver(query: QueryResolver): string;
|
|
181
|
+
declare function printMutationResolver(mutation: MutationResolver): string;
|
|
159
182
|
declare function printMock(mock: Mock, indent?: string): string;
|
|
160
183
|
declare function printCondition(condition: Condition, indent?: string): string;
|
|
161
184
|
declare function printTest(test: It): string;
|
|
@@ -170,4 +193,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
170
193
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
171
194
|
declare function formatWhen(when: When): string;
|
|
172
195
|
|
|
173
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
|
196
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type GraphQLSchema, type It, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.mjs
CHANGED
|
@@ -91,6 +91,9 @@ var Parser = class {
|
|
|
91
91
|
const routes = [];
|
|
92
92
|
const describes = [];
|
|
93
93
|
const comments = [];
|
|
94
|
+
let graphqlSchema;
|
|
95
|
+
const queries = [];
|
|
96
|
+
const mutations = [];
|
|
94
97
|
while (!this.eof()) {
|
|
95
98
|
this.skipWhitespaceOnly();
|
|
96
99
|
if (this.eof()) break;
|
|
@@ -107,6 +110,24 @@ var Parser = class {
|
|
|
107
110
|
configs.push(cfg);
|
|
108
111
|
continue;
|
|
109
112
|
}
|
|
113
|
+
const schema = this.tryParse(() => this.parseGraphQLSchema());
|
|
114
|
+
if (schema) {
|
|
115
|
+
schema.lineNumber = this.getLineNumber(start);
|
|
116
|
+
graphqlSchema = schema;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const query = this.tryParse(() => this.parseQueryResolver());
|
|
120
|
+
if (query) {
|
|
121
|
+
query.lineNumber = this.getLineNumber(start);
|
|
122
|
+
queries.push(query);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const mutation = this.tryParse(() => this.parseMutationResolver());
|
|
126
|
+
if (mutation) {
|
|
127
|
+
mutation.lineNumber = this.getLineNumber(start);
|
|
128
|
+
mutations.push(mutation);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
110
131
|
const namedPipe = this.tryParse(() => this.parseNamedPipeline());
|
|
111
132
|
if (namedPipe) {
|
|
112
133
|
namedPipe.lineNumber = this.getLineNumber(start);
|
|
@@ -146,7 +167,7 @@ var Parser = class {
|
|
|
146
167
|
const start = Math.max(0, idx);
|
|
147
168
|
this.report("Unclosed backtick-delimited string", start, start + 1, "warning");
|
|
148
169
|
}
|
|
149
|
-
return { configs, pipelines, variables, routes, describes, comments };
|
|
170
|
+
return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations };
|
|
150
171
|
}
|
|
151
172
|
eof() {
|
|
152
173
|
return this.pos >= this.len;
|
|
@@ -492,6 +513,42 @@ var Parser = class {
|
|
|
492
513
|
this.skipWhitespaceOnly();
|
|
493
514
|
return { varType, name, value, inlineComment: inlineComment || void 0 };
|
|
494
515
|
}
|
|
516
|
+
parseGraphQLSchema() {
|
|
517
|
+
this.expect("graphql");
|
|
518
|
+
this.skipInlineSpaces();
|
|
519
|
+
this.expect("schema");
|
|
520
|
+
this.skipInlineSpaces();
|
|
521
|
+
this.expect("=");
|
|
522
|
+
const inlineComment = this.parseInlineComment();
|
|
523
|
+
this.skipInlineSpaces();
|
|
524
|
+
const sdl = this.parseBacktickString();
|
|
525
|
+
this.skipWhitespaceOnly();
|
|
526
|
+
return { sdl, inlineComment: inlineComment || void 0 };
|
|
527
|
+
}
|
|
528
|
+
parseQueryResolver() {
|
|
529
|
+
this.expect("query");
|
|
530
|
+
this.skipInlineSpaces();
|
|
531
|
+
const name = this.parseIdentifier();
|
|
532
|
+
this.skipInlineSpaces();
|
|
533
|
+
this.expect("=");
|
|
534
|
+
const inlineComment = this.parseInlineComment();
|
|
535
|
+
this.skipWhitespaceOnly();
|
|
536
|
+
const pipeline = this.parsePipeline();
|
|
537
|
+
this.skipWhitespaceOnly();
|
|
538
|
+
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
539
|
+
}
|
|
540
|
+
parseMutationResolver() {
|
|
541
|
+
this.expect("mutation");
|
|
542
|
+
this.skipInlineSpaces();
|
|
543
|
+
const name = this.parseIdentifier();
|
|
544
|
+
this.skipInlineSpaces();
|
|
545
|
+
this.expect("=");
|
|
546
|
+
const inlineComment = this.parseInlineComment();
|
|
547
|
+
this.skipWhitespaceOnly();
|
|
548
|
+
const pipeline = this.parsePipeline();
|
|
549
|
+
this.skipWhitespaceOnly();
|
|
550
|
+
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
551
|
+
}
|
|
495
552
|
parseRoute() {
|
|
496
553
|
const method = this.parseMethod();
|
|
497
554
|
this.skipInlineSpaces();
|
|
@@ -716,6 +773,39 @@ function printVariable(variable) {
|
|
|
716
773
|
}
|
|
717
774
|
return variableLine;
|
|
718
775
|
}
|
|
776
|
+
function printGraphQLSchema(schema) {
|
|
777
|
+
const schemaLine = `graphql schema = \`${schema.sdl}\``;
|
|
778
|
+
if (schema.inlineComment) {
|
|
779
|
+
return `${schemaLine} ${printComment(schema.inlineComment)}`;
|
|
780
|
+
}
|
|
781
|
+
return schemaLine;
|
|
782
|
+
}
|
|
783
|
+
function printQueryResolver(query) {
|
|
784
|
+
const lines = [];
|
|
785
|
+
const queryLine = `query ${query.name} =`;
|
|
786
|
+
if (query.inlineComment) {
|
|
787
|
+
lines.push(`${queryLine} ${printComment(query.inlineComment)}`);
|
|
788
|
+
} else {
|
|
789
|
+
lines.push(queryLine);
|
|
790
|
+
}
|
|
791
|
+
query.pipeline.steps.forEach((step) => {
|
|
792
|
+
lines.push(formatPipelineStep(step));
|
|
793
|
+
});
|
|
794
|
+
return lines.join("\n");
|
|
795
|
+
}
|
|
796
|
+
function printMutationResolver(mutation) {
|
|
797
|
+
const lines = [];
|
|
798
|
+
const mutationLine = `mutation ${mutation.name} =`;
|
|
799
|
+
if (mutation.inlineComment) {
|
|
800
|
+
lines.push(`${mutationLine} ${printComment(mutation.inlineComment)}`);
|
|
801
|
+
} else {
|
|
802
|
+
lines.push(mutationLine);
|
|
803
|
+
}
|
|
804
|
+
mutation.pipeline.steps.forEach((step) => {
|
|
805
|
+
lines.push(formatPipelineStep(step));
|
|
806
|
+
});
|
|
807
|
+
return lines.join("\n");
|
|
808
|
+
}
|
|
719
809
|
function printMock(mock, indent = " ") {
|
|
720
810
|
return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
|
|
721
811
|
}
|
|
@@ -775,6 +865,15 @@ function prettyPrint(program) {
|
|
|
775
865
|
program.configs.forEach((config) => {
|
|
776
866
|
allItems.push({ type: "config", item: config, lineNumber: config.lineNumber || 0 });
|
|
777
867
|
});
|
|
868
|
+
if (program.graphqlSchema) {
|
|
869
|
+
allItems.push({ type: "graphqlSchema", item: program.graphqlSchema, lineNumber: program.graphqlSchema.lineNumber || 0 });
|
|
870
|
+
}
|
|
871
|
+
program.queries.forEach((query) => {
|
|
872
|
+
allItems.push({ type: "query", item: query, lineNumber: query.lineNumber || 0 });
|
|
873
|
+
});
|
|
874
|
+
program.mutations.forEach((mutation) => {
|
|
875
|
+
allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
|
|
876
|
+
});
|
|
778
877
|
program.routes.forEach((route) => {
|
|
779
878
|
allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
|
|
780
879
|
});
|
|
@@ -800,6 +899,18 @@ function prettyPrint(program) {
|
|
|
800
899
|
lines.push(printConfig(entry.item));
|
|
801
900
|
lines.push("");
|
|
802
901
|
break;
|
|
902
|
+
case "graphqlSchema":
|
|
903
|
+
lines.push(printGraphQLSchema(entry.item));
|
|
904
|
+
lines.push("");
|
|
905
|
+
break;
|
|
906
|
+
case "query":
|
|
907
|
+
lines.push(printQueryResolver(entry.item));
|
|
908
|
+
lines.push("");
|
|
909
|
+
break;
|
|
910
|
+
case "mutation":
|
|
911
|
+
lines.push(printMutationResolver(entry.item));
|
|
912
|
+
lines.push("");
|
|
913
|
+
break;
|
|
803
914
|
case "route":
|
|
804
915
|
lines.push(printRoute(entry.item));
|
|
805
916
|
lines.push("");
|
|
@@ -906,8 +1017,11 @@ export {
|
|
|
906
1017
|
printCondition,
|
|
907
1018
|
printConfig,
|
|
908
1019
|
printDescribe,
|
|
1020
|
+
printGraphQLSchema,
|
|
909
1021
|
printMock,
|
|
1022
|
+
printMutationResolver,
|
|
910
1023
|
printPipeline,
|
|
1024
|
+
printQueryResolver,
|
|
911
1025
|
printRoute,
|
|
912
1026
|
printTest,
|
|
913
1027
|
printVariable
|