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