@devticon-os/graphql-codegen-axios 0.2.17 → 0.3.0-test
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/package.json +11 -4
- package/src/_types.ts +60 -0
- package/src/enums.ts +50 -0
- package/src/fragments.ts +15 -0
- package/src/graphql.ts +101 -0
- package/src/index.ts +70 -0
- package/src/input.ts +65 -0
- package/src/operation.ts +212 -0
- package/src/prettier.ts +13 -0
- package/src/print.ts +139 -0
- package/src/scalar.ts +5 -0
- package/src/utils.ts +1 -0
- package/src/enums.js +0 -35
- package/src/fragments.js +0 -35
- package/src/functions.js +0 -31
- package/src/helpers.ts +0 -59
- package/src/index.js +0 -94
- package/src/input.js +0 -77
- package/src/query.js +0 -14
- package/src/render.js +0 -118
- package/src/results.js +0 -43
- package/src/scalar.js +0 -6
- package/src/types.js +0 -49
- package/src/utils.js +0 -3
- package/src/variables.js +0 -34
package/src/types.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
GraphQLList,
|
|
3
|
-
GraphQLNonNull,
|
|
4
|
-
GraphQLScalarType,
|
|
5
|
-
GraphQLEnumType,
|
|
6
|
-
GraphQLInputObjectType,
|
|
7
|
-
GraphQLObjectType,
|
|
8
|
-
} = require('graphql/type');
|
|
9
|
-
const getGraphqlTypeInfo = (type, isList = false, isNullable = true) => {
|
|
10
|
-
if (type instanceof GraphQLList) {
|
|
11
|
-
isList = true;
|
|
12
|
-
return getGraphqlTypeInfo(type.ofType, isList, isNullable);
|
|
13
|
-
}
|
|
14
|
-
if (type instanceof GraphQLNonNull) {
|
|
15
|
-
isNullable = false;
|
|
16
|
-
return getGraphqlTypeInfo(type.ofType, isList, isNullable);
|
|
17
|
-
}
|
|
18
|
-
const isScalar = type instanceof GraphQLScalarType;
|
|
19
|
-
return { type, isList, isNullable, typeName: type.name, isScalar, gqlType: getGraphqlType(type) };
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getGraphqlType = type => {
|
|
23
|
-
if (type instanceof GraphQLEnumType) {
|
|
24
|
-
return 'enum';
|
|
25
|
-
}
|
|
26
|
-
if (type instanceof GraphQLInputObjectType) {
|
|
27
|
-
return 'input';
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const assignDirectivesToType = (typeInfo, directives) => {
|
|
31
|
-
const newType = { ...typeInfo };
|
|
32
|
-
for (let directive of directives) {
|
|
33
|
-
switch (directive.name.value) {
|
|
34
|
-
case 'firstOrFail':
|
|
35
|
-
newType.isList = false;
|
|
36
|
-
newType.isNullable = false;
|
|
37
|
-
break;
|
|
38
|
-
case 'first':
|
|
39
|
-
newType.isList = false;
|
|
40
|
-
newType.isNullable = true;
|
|
41
|
-
break;
|
|
42
|
-
case 'nonNullable':
|
|
43
|
-
newType.isNullable = false;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return newType;
|
|
48
|
-
};
|
|
49
|
-
module.exports = { getGraphqlTypeInfo, assignDirectivesToType, getGraphqlType };
|
package/src/utils.js
DELETED
package/src/variables.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const { findInputInSchema } = require('./input');
|
|
2
|
-
const { getGraphqlType } = require('./types');
|
|
3
|
-
const { findEnumInSchema } = require('./enums');
|
|
4
|
-
const getVariablesFields = (definition, schema) => {
|
|
5
|
-
return definition.variableDefinitions.map(variable => ({
|
|
6
|
-
name: variable.variable.name.value,
|
|
7
|
-
...getVariableType(variable.type, schema),
|
|
8
|
-
fields: [],
|
|
9
|
-
}));
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getVariableType = (type, schema, isList = false, isNullable = true) => {
|
|
13
|
-
if (type.kind === 'ListType') {
|
|
14
|
-
isList = true;
|
|
15
|
-
return getVariableType(type.type, schema, isList, isNullable);
|
|
16
|
-
}
|
|
17
|
-
if (type.kind === 'NonNullType') {
|
|
18
|
-
isNullable = false;
|
|
19
|
-
return getVariableType(type.type, schema, isList, isNullable);
|
|
20
|
-
}
|
|
21
|
-
const typeName = type.name.value;
|
|
22
|
-
const isScalar = !findInputInSchema(typeName, schema) && !findEnumInSchema(typeName, schema);
|
|
23
|
-
return {
|
|
24
|
-
type: type.type,
|
|
25
|
-
isList,
|
|
26
|
-
isNullable,
|
|
27
|
-
typeName,
|
|
28
|
-
isScalar,
|
|
29
|
-
inLine: !isScalar,
|
|
30
|
-
gqlType: isScalar ? 'scalar' : 'input',
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
module.exports = { getVariablesFields };
|