constructor()

in src/components/operations/operation-details/ko/runtime/graphql-utilities/graphql-node-models.ts [135:173]


    constructor(label: string, data: GraphQL.GraphQLInputField, generateDocument: () => void, parent: GraphQLTreeNode) {
        super(label, generateDocument, parent);
        this.children = ko.observableArray([]); 
        this.data = data;
        this.isRequired = ko.observable(isNonNull(data.type));
        if (this.isRequired()) {
            this.toggle(true, false);
        }

        this.inputValue = ko.observable("");
        const type = getType(data.type);
        if (type instanceof GraphQL.GraphQLEnumType) {
            this.options = ko.observableArray(type.getValues().map(v => v.name));
            if (this.options().length > 0) {
                this.inputValue(this.options()[0]);
            }
        } else if (type instanceof GraphQL.GraphQLScalarType) {
            switch (type.name) {
                case "String":
                    this.inputValue(`"string"`);
                    break;
                case "Int":
                    this.inputValue("10");
                    break;
                case "Float":
                    this.inputValue("0.0");
                    break;
                case "Boolean":
                    this.inputValue("false");
                    break;
                case "ID":
                    this.inputValue(`"id"`);
                    break;
                default:
                    this.inputValue(`""`);
                    break;
            }
        }
    }