@graphql-codegen/java-apollo-android 2.2.13 → 2.3.0-alpha-29eb1293b.0
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/cjs/base-java-visitor.js +114 -0
- package/cjs/custom-type-class.js +69 -0
- package/cjs/field-arguments.js +36 -0
- package/cjs/file-type.js +10 -0
- package/cjs/imports.js +45 -0
- package/cjs/index.js +5 -0
- package/cjs/input-type-visitor.js +187 -0
- package/cjs/operation-visitor.js +780 -0
- package/cjs/package.json +1 -0
- package/cjs/plugin.js +48 -0
- package/cjs/preset.js +95 -0
- package/cjs/types.js +2 -0
- package/cjs/visitor-config.js +2 -0
- package/esm/base-java-visitor.js +110 -0
- package/esm/custom-type-class.js +65 -0
- package/esm/field-arguments.js +32 -0
- package/esm/file-type.js +7 -0
- package/esm/imports.js +42 -0
- package/esm/index.js +2 -0
- package/esm/input-type-visitor.js +183 -0
- package/{index.mjs → esm/operation-visitor.js} +8 -565
- package/esm/plugin.js +44 -0
- package/esm/preset.js +92 -0
- package/esm/types.js +1 -0
- package/esm/visitor-config.js +1 -0
- package/package.json +23 -16
- package/{base-java-visitor.d.ts → typings/base-java-visitor.d.ts} +3 -3
- package/{custom-type-class.d.ts → typings/custom-type-class.d.ts} +3 -3
- package/{field-arguments.d.ts → typings/field-arguments.d.ts} +1 -1
- package/{file-type.d.ts → typings/file-type.d.ts} +0 -0
- package/{imports.d.ts → typings/imports.d.ts} +0 -0
- package/typings/index.d.ts +2 -0
- package/{input-type-visitor.d.ts → typings/input-type-visitor.d.ts} +3 -3
- package/{operation-visitor.d.ts → typings/operation-visitor.d.ts} +3 -3
- package/{plugin.d.ts → typings/plugin.d.ts} +1 -1
- package/{preset.d.ts → typings/preset.d.ts} +0 -0
- package/{types.d.ts → typings/types.d.ts} +0 -0
- package/{visitor-config.d.ts → typings/visitor-config.d.ts} +0 -0
- package/index.d.ts +0 -2
- package/index.js +0 -1339
package/esm/preset.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { visit, concatAST, Kind, } from 'graphql';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { FileType } from './file-type.js';
|
|
4
|
+
import { pascalCase } from 'change-case-all';
|
|
5
|
+
const packageNameToDirectory = (packageName) => {
|
|
6
|
+
return `./${packageName.split('.').join('/')}/`;
|
|
7
|
+
};
|
|
8
|
+
export const preset = {
|
|
9
|
+
buildGeneratesSection: options => {
|
|
10
|
+
const outDir = options.baseOutputDir;
|
|
11
|
+
const inputTypesAst = [];
|
|
12
|
+
visit(options.schema, {
|
|
13
|
+
InputObjectTypeDefinition: {
|
|
14
|
+
enter(node) {
|
|
15
|
+
inputTypesAst.push(node);
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const inputTypesDocumentNode = { kind: Kind.DOCUMENT, definitions: inputTypesAst };
|
|
20
|
+
const allAst = concatAST(options.documents.map(v => v.document));
|
|
21
|
+
const operationsAst = allAst.definitions.filter(d => d.kind === Kind.OPERATION_DEFINITION);
|
|
22
|
+
const fragments = allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION);
|
|
23
|
+
const externalFragments = fragments.map(frag => ({
|
|
24
|
+
isExternal: true,
|
|
25
|
+
importFrom: frag.name.value,
|
|
26
|
+
name: frag.name.value,
|
|
27
|
+
onType: frag.typeCondition.name.value,
|
|
28
|
+
node: frag,
|
|
29
|
+
}));
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
filename: join(outDir, packageNameToDirectory(options.config.typePackage), 'CustomType.java'),
|
|
33
|
+
plugins: options.plugins,
|
|
34
|
+
pluginMap: options.pluginMap,
|
|
35
|
+
config: {
|
|
36
|
+
...options.config,
|
|
37
|
+
fileType: FileType.CUSTOM_TYPES,
|
|
38
|
+
},
|
|
39
|
+
schema: options.schema,
|
|
40
|
+
documents: [],
|
|
41
|
+
},
|
|
42
|
+
...inputTypesDocumentNode.definitions.map((ast) => {
|
|
43
|
+
const document = { kind: Kind.DOCUMENT, definitions: [ast] };
|
|
44
|
+
return {
|
|
45
|
+
filename: join(outDir, packageNameToDirectory(options.config.typePackage), ast.name.value + '.java'),
|
|
46
|
+
plugins: options.plugins,
|
|
47
|
+
pluginMap: options.pluginMap,
|
|
48
|
+
config: {
|
|
49
|
+
...options.config,
|
|
50
|
+
fileType: FileType.INPUT_TYPE,
|
|
51
|
+
skipDocumentsValidation: true,
|
|
52
|
+
},
|
|
53
|
+
schema: options.schema,
|
|
54
|
+
documents: [{ document, location: '' }],
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
...operationsAst.map((ast) => {
|
|
58
|
+
const fileName = ast.name.value.toLowerCase().endsWith(ast.operation)
|
|
59
|
+
? ast.name.value
|
|
60
|
+
: `${ast.name.value}${pascalCase(ast.operation)}`;
|
|
61
|
+
const document = { kind: Kind.DOCUMENT, definitions: [ast] };
|
|
62
|
+
return {
|
|
63
|
+
filename: join(outDir, packageNameToDirectory(options.config.package), fileName + '.java'),
|
|
64
|
+
plugins: options.plugins,
|
|
65
|
+
pluginMap: options.pluginMap,
|
|
66
|
+
config: {
|
|
67
|
+
...options.config,
|
|
68
|
+
fileType: FileType.OPERATION,
|
|
69
|
+
externalFragments,
|
|
70
|
+
},
|
|
71
|
+
schema: options.schema,
|
|
72
|
+
documents: [{ document, location: '' }],
|
|
73
|
+
};
|
|
74
|
+
}),
|
|
75
|
+
...fragments.map((ast) => {
|
|
76
|
+
const document = { kind: Kind.DOCUMENT, definitions: [ast] };
|
|
77
|
+
return {
|
|
78
|
+
filename: join(outDir, packageNameToDirectory(options.config.fragmentPackage), ast.name.value + '.java'),
|
|
79
|
+
plugins: options.plugins,
|
|
80
|
+
pluginMap: options.pluginMap,
|
|
81
|
+
config: {
|
|
82
|
+
...options.config,
|
|
83
|
+
fileType: FileType.FRAGMENT,
|
|
84
|
+
externalFragments,
|
|
85
|
+
},
|
|
86
|
+
schema: options.schema,
|
|
87
|
+
documents: [{ document, location: '' }],
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
];
|
|
91
|
+
},
|
|
92
|
+
};
|
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/java-apollo-android",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha-29eb1293b.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating Java classes for Apollo-Android",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-codegen/java-common": "^2.
|
|
10
|
-
"@graphql-codegen/plugin-helpers": "^2.
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "2.
|
|
9
|
+
"@graphql-codegen/java-common": "^2.2.0-alpha-29eb1293b.0",
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "^2.5.0-alpha-29eb1293b.0",
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-29eb1293b.0",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"change-case-all": "1.0.14",
|
|
14
14
|
"pluralize": "^8.0.0",
|
|
@@ -20,21 +20,28 @@
|
|
|
20
20
|
"directory": "packages/plugins/java/apollo-android"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
|
-
"main": "index.js",
|
|
24
|
-
"module": "index.
|
|
25
|
-
"typings": "index.d.ts",
|
|
23
|
+
"main": "cjs/index.js",
|
|
24
|
+
"module": "esm/index.js",
|
|
25
|
+
"typings": "typings/index.d.ts",
|
|
26
26
|
"typescript": {
|
|
27
|
-
"definition": "index.d.ts"
|
|
27
|
+
"definition": "typings/index.d.ts"
|
|
28
28
|
},
|
|
29
|
+
"type": "module",
|
|
29
30
|
"exports": {
|
|
30
|
-
"./package.json": "./package.json",
|
|
31
31
|
".": {
|
|
32
|
-
"require":
|
|
33
|
-
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./typings/index.d.ts",
|
|
34
|
+
"default": "./cjs/index.js"
|
|
35
|
+
},
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./typings/index.d.ts",
|
|
38
|
+
"default": "./esm/index.js"
|
|
39
|
+
},
|
|
40
|
+
"default": {
|
|
41
|
+
"types": "./typings/index.d.ts",
|
|
42
|
+
"default": "./esm/index.js"
|
|
43
|
+
}
|
|
34
44
|
},
|
|
35
|
-
"
|
|
36
|
-
"require": "./*.js",
|
|
37
|
-
"import": "./*.mjs"
|
|
38
|
-
}
|
|
45
|
+
"./package.json": "./package.json"
|
|
39
46
|
}
|
|
40
|
-
}
|
|
47
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseVisitor } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
-
import { JavaApolloAndroidPluginConfig } from './plugin';
|
|
2
|
+
import { JavaApolloAndroidPluginConfig } from './plugin.js';
|
|
3
3
|
import { GraphQLSchema, GraphQLNamedType, GraphQLOutputType, TypeNode, GraphQLInterfaceType } from 'graphql';
|
|
4
|
-
import { VisitorConfig } from './visitor-config';
|
|
5
|
-
import { ImportsSet, TransformedType } from './types';
|
|
4
|
+
import { VisitorConfig } from './visitor-config.js';
|
|
5
|
+
import { ImportsSet, TransformedType } from './types.js';
|
|
6
6
|
export declare const SCALAR_TO_WRITER_METHOD: {
|
|
7
7
|
ID: string;
|
|
8
8
|
String: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { BaseJavaVisitor } from './base-java-visitor';
|
|
3
|
-
import { VisitorConfig } from './visitor-config';
|
|
4
|
-
import { JavaApolloAndroidPluginConfig } from './plugin';
|
|
2
|
+
import { BaseJavaVisitor } from './base-java-visitor.js';
|
|
3
|
+
import { VisitorConfig } from './visitor-config.js';
|
|
4
|
+
import { JavaApolloAndroidPluginConfig } from './plugin.js';
|
|
5
5
|
export declare class CustomTypeClassVisitor extends BaseJavaVisitor<VisitorConfig> {
|
|
6
6
|
constructor(schema: GraphQLSchema, rawConfig: JavaApolloAndroidPluginConfig);
|
|
7
7
|
private extract;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { JavaApolloAndroidPluginConfig } from './plugin';
|
|
1
|
+
import { JavaApolloAndroidPluginConfig } from './plugin.js';
|
|
2
2
|
import { InputObjectTypeDefinitionNode, GraphQLSchema, InputValueDefinitionNode, VariableDefinitionNode } from 'graphql';
|
|
3
|
-
import { BaseJavaVisitor } from './base-java-visitor';
|
|
4
|
-
import { VisitorConfig } from './visitor-config';
|
|
3
|
+
import { BaseJavaVisitor } from './base-java-visitor.js';
|
|
4
|
+
import { VisitorConfig } from './visitor-config.js';
|
|
5
5
|
export declare class InputTypeVisitor extends BaseJavaVisitor<VisitorConfig> {
|
|
6
6
|
constructor(_schema: GraphQLSchema, rawConfig: JavaApolloAndroidPluginConfig);
|
|
7
7
|
getPackage(): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseJavaVisitor } from './base-java-visitor';
|
|
1
|
+
import { BaseJavaVisitor } from './base-java-visitor.js';
|
|
2
2
|
import { LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
3
3
|
import { JavaDeclarationBlock } from '@graphql-codegen/java-common';
|
|
4
4
|
import { GraphQLSchema, OperationDefinitionNode, GraphQLNamedType, SelectionNode, GraphQLOutputType, FragmentDefinitionNode } from 'graphql';
|
|
5
|
-
import { JavaApolloAndroidPluginConfig } from './plugin';
|
|
6
|
-
import { VisitorConfig } from './visitor-config';
|
|
5
|
+
import { JavaApolloAndroidPluginConfig } from './plugin.js';
|
|
6
|
+
import { VisitorConfig } from './visitor-config.js';
|
|
7
7
|
export interface ChildField {
|
|
8
8
|
type: GraphQLNamedType;
|
|
9
9
|
rawType: GraphQLOutputType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFunction, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { RawConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
3
|
-
import { FileType } from './file-type';
|
|
3
|
+
import { FileType } from './file-type.js';
|
|
4
4
|
/**
|
|
5
5
|
* @description This plugin and presets creates generated mappers and parsers for a complete type-safe GraphQL requests, for developers that uses Apollo Android runtime.
|
|
6
6
|
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/index.d.ts
DELETED