in src/components/operations/operation-details/ko/runtime/graphql-documentation/graphql-doc-service.ts [68:121]
private async defaultValues(): Promise<void> {
await this.getApi(this.selectedApiName());
if (this.api().type === TypeOfApi.graphQL) {
const graphQLSchema = await this.apiService.getGQLSchema(this.api().id);
if (!graphQLSchema) {
return;
}
this.content(graphQLSchema.graphQLSchema);
const schema = GraphQL.buildSchema(this.content(), { commentDescriptions: true });
this.docGraphs.query(schema.getQueryType()?.getFields());
this.docGraphs.mutation(schema.getMutationType()?.getFields());
this.docGraphs.subscription(schema.getSubscriptionType()?.getFields());
const typeMap = schema.getTypeMap();
this.docGraphs.objectType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLObjectType);
}));
this.docGraphs.inputObjectType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLInputObjectType);
}));
this.docGraphs.enumType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLEnumType);
}));
this.docGraphs.scalarType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLScalarType);
}));
this.docGraphs.unionType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLUnionType);
}));
this.docGraphs.interfaceType(_.pickBy(typeMap, (t) => {
return (t instanceof GraphQL.GraphQLInterfaceType);
}));
_.forEach(this.docGraphs, (value, key) => {
const valueData = value();
this.addingNewFields(valueData, key);
if (key == GraphqlTypes.query || key == GraphqlTypes.subscription || key == GraphqlTypes.mutation) {
value(this.sortingAlphabetically(valueData));
}
});
for (const type in GraphqlTypesForDocumentation) {
if (_.size(this.docGraphs[type]()) > 0) {
const selectedCollection = this.docGraphs[type]();
const selectedGraph = selectedCollection[Object.keys(selectedCollection)[0]];
this.select(selectedGraph);
break;
}
}
this.getAvailableTypes();
}
}