Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected resolveInputFieldType(typeNode: TypeNode): { baseType: string; typeName: string; isScalar: boolean; isArray: boolean; nullable: boolean } {
const innerType = getBaseTypeNode(typeNode);
const schemaType = this._schema.getType(innerType.name.value);
const isArray = typeNode.kind === Kind.LIST_TYPE || (typeNode.kind === Kind.NON_NULL_TYPE && typeNode.type.kind === Kind.LIST_TYPE);
let result: { baseType: string; typeName: string; isScalar: boolean; isArray: boolean; nullable: boolean } = null;
const nullable = typeNode.kind !== Kind.NON_NULL_TYPE;
if (isScalarType(schemaType)) {
if (this.config.scalars[schemaType.name]) {
result = {
baseType: this.scalars[schemaType.name],
typeName: this.scalars[schemaType.name],
isScalar: true,
isArray,
nullable: nullable,
};
} else {
result = { isArray, baseType: 'Any', typeName: 'Any', isScalar: true, nullable: nullable };protected resolveInputFieldType(typeNode: TypeNode): { baseType: string; typeName: string; isScalar: boolean; isArray: boolean } {
const innerType = getBaseTypeNode(typeNode);
const schemaType = this._schema.getType(innerType.name.value);
const isArray = typeNode.kind === Kind.LIST_TYPE || (typeNode.kind === Kind.NON_NULL_TYPE && typeNode.type.kind === Kind.LIST_TYPE);
let result: { baseType: string; typeName: string; isScalar: boolean; isArray: boolean } = null;
if (isScalarType(schemaType)) {
if (this.scalars[schemaType.name]) {
result = {
baseType: this.scalars[schemaType.name],
typeName: this.scalars[schemaType.name],
isScalar: true,
isArray,
};
} else {
result = { isArray, baseType: 'Object', typeName: 'Object', isScalar: true };
}
} else if (isInputObjectType(schemaType)) {private _handleColumnField(fieldNode: FieldDefinitionNode, tree: FieldsTree, columnDirective: DirectiveNode, mapPath: string | null, addOptionalSign: boolean): void {
const overrideType = this._getDirectiveArgValue(columnDirective, 'overrideType');
const coreType = getBaseTypeNode(fieldNode.type);
let type: string = null;
if (this.scalars[coreType.name.value]) {
type = this.scalars[coreType.name.value];
} else {
const schemaType = this._schema.getType(coreType.name.value);
if (isEnumType(schemaType) && this.config.enumsAsString) {
type = this.scalars.String;
} else {
type = coreType.name.value;
}
}
tree.addField(mapPath ? mapPath : `${fieldNode.name.value}${addOptionalSign ? '?' : ''}`, overrideType ? overrideType : this._variablesTransformer.wrapAstTypeWithModifiers(type, fieldNode.type));
}private _handleLinkField(fieldNode: FieldDefinitionNode, tree: FieldsTree, linkDirective: DirectiveNode, mapPath: string | null, addOptionalSign: boolean): void {
const overrideType = this._getDirectiveArgValue(linkDirective, 'overrideType');
const coreType = overrideType ? overrideType : getBaseTypeNode(fieldNode.type);
const type = this.convertName(coreType, { suffix: this.config.dbTypeSuffix });
tree.addField(mapPath ? mapPath : `${fieldNode.name.value}${addOptionalSign ? '?' : ''}`, this._variablesTransformer.wrapAstTypeWithModifiers(`${type}['${this.config.idFieldName}']`, fieldNode.type));
}private _handleEmbeddedField(fieldNode: FieldDefinitionNode, tree: FieldsTree, mapPath: string | null, addOptionalSign: boolean): void {
const coreType = getBaseTypeNode(fieldNode.type);
const type = this.convertName(coreType, { suffix: this.config.dbTypeSuffix });
tree.addField(mapPath ? mapPath : `${fieldNode.name.value}${addOptionalSign ? '?' : ''}`, this._variablesTransformer.wrapAstTypeWithModifiers(type, fieldNode.type));
}return (isInterface: boolean) => {
const baseType = getBaseTypeNode(node.type);
const typeToUse = this.getTypeToUse(baseType);
const wrappedType = wrapTypeWithModifiers(typeToUse, node.type, this.config.listType);
if (isInterface) {
return `default public DataFetcher<${wrappedType}> ${node.name.value}() { return null; }`;
} else {
return `public DataFetcher<${wrappedType}> ${node.name.value}();`;
}
};
}.map(v => {
const baseTypeNode = getBaseTypeNode(v.type);
const schemaType = this._schema.getType(baseTypeNode.name.value);
const writerMethod = this._getWriterMethodByType(schemaType, true);
return indent(
`writer.${writerMethod.name}("${v.variable.name.value}", ${writerMethod.checkNull ? `${v.variable.name.value} != null ? ${v.variable.name.value}${writerMethod.useMarshaller ? '.marshaller()' : ''} : null` : v.variable.name.value});`,
2
);
})
.join('\n')}node.variableDefinitions.map(varDec => {
const outputType = getBaseTypeNode(varDec.type).name.value;
const schemaType = this._schema.getType(outputType);
const javaClass = this.getJavaClass(schemaType);
const typeToUse = this.getListTypeNodeWrapped(javaClass, varDec.type);
const isNonNull = varDec.type.kind === Kind.NON_NULL_TYPE;
return {
name: varDec.variable.name.value,
type: typeToUse,
annotations: [isNonNull ? 'Nonnull' : 'Nullable'],
};
}),
null,