GraphQL
Generate a GraphQL schema: types, interfaces, scalars and enums, but no queries.
ohi get w3c/prov-oohi linkml to graphql --pruning-mode schema \ --to prov-o.graphql prov-o.linkml.yamlimport ohi_linkml
with ohi_linkml.load_file("prov-o.linkml.yaml") as schema: output = schema.graphql(pruning_mode="schema")import { readFileSync } from "node:fs";import { LinkML } from "@neverblink/linkml";
const yaml = readFileSync("prov-o.linkml.yaml", "utf8");const { view, report } = LinkML.loadFromString(yaml, {});if (!view) throw new Error(JSON.stringify(report));const output = view.graphql({ pruning_mode: "schema" });import eu.neverblink.linkml.generator.options.*import eu.neverblink.linkml.generator.graphql.GraphQlGeneratorimport eu.neverblink.linkml.schemaview.{SchemaIssues, SchemaView}
val loaded = SchemaView.loadSchemaViewFromUri("prov-o.linkml.yaml")given SchemaView = SchemaIssues.orThrow(loaded)val output = GraphQlGenerator().serialize( GraphQlGeneratorOptions(pruningMode = PruningMode.Schema),)#include <stddef.h>#include "ohi_linkml.h"
linkml_init_threads();char *report = NULL, *error = NULL;long long schema = linkml_load_file("prov-o.linkml.yaml", NULL, &report, &error);char *output = linkml_graphql( schema, "{\"pruning_mode\": \"schema\"}", &error);linkml_free(output);linkml_free(report);linkml_free(error);linkml_close(schema);Options
Section titled “Options”metadata_languagestringdefault enCLI
--metadata-languageScala metadataLanguageThe language of the titles and descriptions in the output, for schemas with text in more than one language.
pruning_modePruningModedefault schemaCLI
--pruning-modeScala pruningModeThe elements of the schema to include in the output.
tree_rootThe elements reachable from the tree root class. Without a tree root, the same asschema.schemaEverything defined in the root schema, and every element reachable from it. This leaves out the unused parts of imported schemas, such as most oflinkml:types.skipEvery element of the root schema and of all its imports.
tree_rootstringCLI
--tree-rootScala treeRootThe class to use as the tree root, instead of the class with tree_root: true in the schema. Only for the tree_root pruning mode.