UNPKG

4.54 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const helpers_1 = require("./helpers");
4const types_1 = require("./types");
5exports.plugins = [
6 {
7 name: `TypeScript ${helpers_1.italic('(required by other typescript plugins)')}`,
8 package: 'graphql-codegen-typescript',
9 value: 'typescript',
10 available: hasTag(types_1.Tags.typescript),
11 shouldBeSelected: tags => oneOf(tags, types_1.Tags.angular, types_1.Tags.stencil) || allOf(tags, types_1.Tags.typescript, types_1.Tags.react) || noneOf(tags, types_1.Tags.flow)
12 },
13 {
14 name: `TypeScript Operations ${helpers_1.italic('(operations and fragments)')}`,
15 package: 'graphql-codegen-typescript-operations',
16 value: 'typescript-operations',
17 available: tags => allOf(tags, types_1.Tags.browser, types_1.Tags.typescript),
18 shouldBeSelected: tags => oneOf(tags, types_1.Tags.angular, types_1.Tags.stencil) || allOf(tags, types_1.Tags.typescript, types_1.Tags.react)
19 },
20 {
21 name: `TypeScript Resolvers ${helpers_1.italic('(strongly typed resolve functions)')}`,
22 package: 'graphql-codegen-typescript-resolvers',
23 value: 'typescript-resolvers',
24 available: tags => allOf(tags, types_1.Tags.node, types_1.Tags.typescript),
25 shouldBeSelected: tags => noneOf(tags, types_1.Tags.flow)
26 },
27 {
28 name: `Flow ${helpers_1.italic('(required by other flow plugins)')}`,
29 package: 'graphql-codegen-flow',
30 value: 'flow',
31 available: hasTag(types_1.Tags.flow),
32 shouldBeSelected: tags => noneOf(tags, types_1.Tags.typescript)
33 },
34 {
35 name: `Flow Operations ${helpers_1.italic('(operations and fragments)')}`,
36 package: 'graphql-codegen-flow-operations',
37 value: 'flow-operations',
38 available: tags => allOf(tags, types_1.Tags.browser, types_1.Tags.flow),
39 shouldBeSelected: tags => noneOf(tags, types_1.Tags.typescript)
40 },
41 {
42 name: `Flow Resolvers ${helpers_1.italic('(strongly typed resolve functions)')}`,
43 package: 'graphql-codegen-flow-resolvers',
44 value: 'flow-resolvers',
45 available: tags => allOf(tags, types_1.Tags.node, types_1.Tags.flow),
46 shouldBeSelected: tags => noneOf(tags, types_1.Tags.typescript)
47 },
48 {
49 name: `TypeScript Apollo Angular ${helpers_1.italic('(typed GQL services)')}`,
50 package: 'graphql-codegen-typescript-apollo-angular',
51 value: 'typescript-apollo-angular',
52 available: hasTag(types_1.Tags.angular),
53 shouldBeSelected: () => true
54 },
55 {
56 name: `TypeScript React Apollo ${helpers_1.italic('(typed components and HOCs)')}`,
57 package: 'graphql-codegen-typescript-react-apollo',
58 value: 'typescript-react-apollo',
59 available: tags => allOf(tags, types_1.Tags.react, types_1.Tags.typescript),
60 shouldBeSelected: () => true
61 },
62 {
63 name: `TypeScript Stencil Apollo ${helpers_1.italic('(typed components)')}`,
64 package: 'graphql-codegen-typescript-stencil-apollo',
65 value: 'typescript-stencil-apollo',
66 available: hasTag(types_1.Tags.stencil),
67 shouldBeSelected: () => true
68 },
69 {
70 name: `TypeScript MongoDB ${helpers_1.italic('(typed MongoDB objects)')}`,
71 package: 'graphql-codegen-typescript-mongodb',
72 value: 'typescript-mongodb',
73 available: tags => allOf(tags, types_1.Tags.node, types_1.Tags.typescript),
74 shouldBeSelected: () => false
75 },
76 {
77 name: `TypeScript GraphQL files modules ${helpers_1.italic('(declarations for .graphql files)')}`,
78 package: 'graphql-codegen-typescript-graphql-files-modules',
79 value: 'typescript-graphql-files-modules',
80 available: tags => allOf(tags, types_1.Tags.browser, types_1.Tags.typescript),
81 shouldBeSelected: () => false
82 },
83 {
84 name: `Introspection Fragment Matcher ${helpers_1.italic('(for Apollo Client)')}`,
85 package: 'graphql-codegen-fragment-matcher',
86 value: 'fragment-matcher',
87 available: hasTag(types_1.Tags.browser),
88 shouldBeSelected: () => false
89 }
90];
91function hasTag(tag) {
92 return (tags) => tags.includes(tag);
93}
94function oneOf(list, ...items) {
95 return list.some(i => items.includes(i));
96}
97function noneOf(list, ...items) {
98 return !list.some(i => items.includes(i));
99}
100function allOf(list, ...items) {
101 return items.every(i => list.includes(i));
102}
103//# sourceMappingURL=plugins.js.map
\No newline at end of file