@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix	gql: <http://www.openlinksw.com/schemas/graphql#> .
@prefix gqi: <http://www.openlinksw.com/schemas/graphql/intro#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> . 
@prefix wdrs: <http://www.w3.org/2007/05/powder-s#> . 
@prefix : <http://www.openlinksw.com/schemas/graphql#> .
@prefix current-doc: <> . 

:schema a owl:Ontology ;
    wdrs:describedby current-doc: ;
    rdfs:label "RDF Ontology to GraphQL mappings schema" ;
    rdfs:comment """
    This ontology descibe terms for annotating classes and properties that inform the behavior of our GraphQL/SPARQL bridge.
    These annotations can be used with a dataset-specific OWL/RDF ontology to enabled data access using GraphQL payloads via HTTP.
    """ ;
    dct:created "2022-07-03"^^xsd:date ; 
    dct:modified "2022-07-14"^^xsd:date ;
    <http://open.vocab.org/terms/defines> 
            gql:Map, gql:MappingObject,
            gql:schemaObjects, 
            gql:dataGraph, 
            gql:schemaGraph, 
            gql:inferenceName,
            gql:iriPattern,
            gql:mutationType,
            gql:sparqlQuery,
            gql:rdfClass, 
            gql:field, 
            gql:type,
            gql:Function,
            gql:Scalar,
            gql:Boolean,
            gql:Object,
            gql:Array .

:Map a owl:Class ;
    rdfs:label "Map"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "The root object of GraphQL/SPARQL bridge annotation properties" .

:Scalar a gql:MappingObject ;
    rdfs:label "Scalar"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "Common object for all scalar types e.g. String, Int, Float etc., if a field is not present defaults to `null`" .

:Boolean a gql:MappingObject ;
    rdfs:label "Boolean"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "Object for scalar type `Boolean`, when a field is not present defaults to `false`" .

:Object a gql:MappingObject ;
    rdfs:label "Object"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "Class representing GraphQL type `OBJECT`" .

:Function a gql:MappingObject ;
    rdfs:label "Function"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "Class representing `SPARQL` query" .

:Array a gql:MappingObject ;
    rdfs:label "Array"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment "Class representing GraphQL type `LIST`" .

:MappingObject a owl:Class ;
    rdfs:label "MappingObject"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment """
        This is a core mapping class, all objects representing GraphQL objects and fields are instance of this class. 
        All instance denotations MUST be scoped to the namespace prefix `gql: <http://www.openlinksw.com/schemas/graphql#>`. 
        Example: query { planet { order_num } } will use `gql:planet` and `gql:order_num` to find associated RDF class and property. 
        RDF terms mappings should be defined using the form:  `gql:planet gql:rdfClass ex:Planet` and `ex:planetOrder gql:field gql:order_num`. 
        """ .


:schemaObjects a owl:ObjectProperty ;
    rdfs:label "schemaObjects"@en ;
	rdfs:isDefinedBy :schema ;
    rdfs:comment "List of mappings between GraphQL and RDF objects and fields." ;
 	rdfs:range gql:MappingObject ;
	rdfs:domain gql:Map .
    
:dataGraph a owl:DatatypeProperty ;
    rdfs:label "dataGraph"@en ;
	rdfs:isDefinedBy :schema ;
    rdfs:comment "The IRI of graph containing the RDF Dataset." ;
 	rdfs:range rdf:Resource ;
	rdfs:domain gql:Map .

:schemaGraph a owl:DatatypeProperty ;
    rdfs:label "schemaGraph"@en ;
	rdfs:isDefinedBy :schema ;
    rdfs:comment "The IRI of the schema (`self`)." ;
 	rdfs:range rdfs:Resource ;
	rdfs:domain gql:Map .


:inferenceName a owl:DatatypeProperty ;
    rdfs:label "inferenceName"@en ;
	rdfs:isDefinedBy :schema ;
    rdfs:comment "The label of RDF inference rule used to query RDF data" ;
 	rdfs:range xsd:string ;
	rdfs:domain gql:Map .

:iriPattern a owl:DatatypeProperty ;
    rdfs:label "iriPattern"@en ;
	rdfs:isDefinedBy :schema ;
        rdfs:comment "A `sprintf` format string that denotes instances of `this` class" ;
 	rdfs:range xsd:string ;
	rdfs:domain owl:Class .

:mutationType a owl:DatatypeProperty ;
    rdfs:label "mutationType"@en ;
	rdfs:isDefinedBy :schema ;
        rdfs:comment "Type of operation used to perform basic mutation operations on instances of `this` class, `INSERT` or `DELETE`" ;
 	rdfs:range xsd:string ;
	rdfs:domain owl:Class .

:sparqlQuery a owl:DatatypeProperty ;
    rdfs:label "sparqlQuery"@en ;
	rdfs:isDefinedBy :schema ;
        rdfs:comment "`SPARQL` query text for `gql:Function` field types" ;
 	rdfs:range xsd:string ;
	rdfs:domain owl:Class .

:rdfClass a owl:ObjectProperty ;
    rdfs:label "rdfClass"@en ;
	rdfs:isDefinedBy :schema ;
        rdfs:comment "Mapping between an OWL/RDF class and GraphQL mapping object listed in `schemaObjects` " ;
 	rdfs:range owl:Class ;
	rdfs:domain rdfs:MappingObject .

:field a owl:ObjectProperty ;
    rdfs:label "field"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment """Mapping of a RDF property to a GraphQL field name.
     This property is used to match a given input field from a GraphQL query 
     to a property associated with matching OWL/RDF class""" ;
    rdfs:range rdfs:MappingObject ;
    rdfs:domain owl:ObjectProperty, owl:DatatypeProperty .

:type a owl:ObjectProperty ;
    rdfs:label "type"@en ;
    rdfs:isDefinedBy :schema ;
    rdfs:comment 
    """Mapping of a RDF property to `SCALAR`, `OBJECT` and `LIST` GraphQL types. 
    This property is used in output serialisation (for ex. `JSON`) to represent nodes and leafs in the results tree""" ;
    rdfs:range gql:Scalar, gql:Object, gql:Array ;
    rdfs:domain owl:ObjectProperty, owl:DatatypeProperty .


