GraphQL#
GraphQL is a language for describing the structure of data to be returned in an API.
Note
This generator will only create GraphQL definitions, it will not create runtime bindings.
Example Output#
Overview#
Graphql can be generated from a LinkML schema.
To run:
gen-graphql personinfo.yaml > personinfo.graphql
Inheritance#
type Person implements HasAliases
{
id: String!
name: String
description: String
image: String
primaryEmail: String
birthDate: String
ageInYears: Integer
gender: GenderType
currentAddress: Address
hasEmploymentHistory: [EmploymentEvent]
hasFamilialRelationships: [FamilialRelationship]
hasMedicalHistory: [MedicalEvent]
aliases: [String]
}
Docs#
Command Line#
gen-graphql#
Generate graphql representation of a LinkML model
gen-graphql [OPTIONS] YAMLFILE
Options
- --strict-naming#
Treat warnings about invalid names or schema elements as errors.
- Default:
False
- -V, --version#
Show the version and exit.
- -f, --format <format>#
Output format
- Default:
'graphql'
- Options:
graphql
- --metadata, --no-metadata#
Include metadata in output
- Default:
True
- --useuris, --metauris#
Use class and slot URIs over model uris
- Default:
True
- -im, --importmap <importmap>#
Import mapping file
- --log_level <log_level>#
Logging level
- Default:
'WARNING'
- Options:
CRITICAL | ERROR | WARNING | INFO | DEBUG
- -v, --verbose#
Verbosity. Takes precedence over –log_level.
- --mergeimports, --no-mergeimports#
Merge imports into source file (default=mergeimports)
- --stacktrace, --no-stacktrace#
Print a stack trace when an error occurs
- Default:
False
Arguments
- YAMLFILE#
Required argument
Code#
- class linkml.generators.graphqlgen.GraphqlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition, ForwardRef('Generator'), pathlib.Path], schemaview: Optional[linkml_runtime.utils.schemaview.SchemaView] = None, format: Optional[str] = None, metadata: bool = True, useuris: Optional[bool] = None, log_level: Optional[int] = 30, mergeimports: Optional[bool] = True, source_file_date: Optional[str] = None, source_file_size: Optional[int] = None, logger: Optional[logging.Logger] = None, verbose: Optional[bool] = None, output: Optional[str] = None, namespaces: Optional[linkml_runtime.utils.namespaces.Namespaces] = None, directory_output: bool = False, base_dir: str = None, metamodel_name_map: Dict[str, str] = None, importmap: Union[str, Mapping[str, str], NoneType] = None, emit_prefixes: Set[str] = <factory>, metamodel: linkml.utils.schemaloader.SchemaLoader = None, stacktrace: bool = False, include: Union[str, pathlib.Path, linkml_runtime.linkml_model.meta.SchemaDefinition, NoneType] = None, strict_naming: bool = False, **_kwargs)[source]#