端点返回的内容类型:文本/html,对于某些查询而未经验证



这是原始问题(这是第二部分)。

我正在使用HyperGraphQl根据本教程查询EBI-RDF SPARQL端点。

当我执行此GraphQl查询以检索GO_0044727的父母:

{
  Class_GET_BY_ID(uris:[
    "http://purl.obolibrary.org/obo/GO_0044727"]) {
    id
    label
    subClassOf {
      id
      label
      subClassOf {
        id
        label
        subClassOf {  # <--- 4th sub level
          id
          label
        }
      }
    }
  }
}

我没有结果:

{
  "extensions": {},
  "data": {
    "@context": {
      "_type": "@type",
      "_id": "@id",
      "label": "http://www.w3.org/2000/01/rdf-schema#label",
      "id": "http://www.geneontology.org/formats/oboInOwl#id",
      "Class_GET_BY_ID": "http://hypergraphql.org/query/Class_GET_BY_ID",
      "subClassOf": "http://www.w3.org/2000/01/rdf-schema#subClassOf"
    },
    "Class_GET_BY_ID": []
  },
  "errors": []
}

在日志中,我收到了错误:

java.util.concurrent.ExecutionException: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.hypergraphql.datafetching.services.SPARQLEndpointService.iterateFutureResults(SPARQLEndpointService.java:86)
    at org.hypergraphql.datafetching.services.SPARQLEndpointService.executeQuery(SPARQLEndpointService.java:69)
    at org.hypergraphql.datafetching.ExecutionTreeNode.generateTreeModel(ExecutionTreeNode.java:357)
    at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:21)
    at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:8)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:377)
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:344)
    at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:81)
    at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:33)
    ... 4 more

基于上面的GraphQl查询生成的SPARQL查询:

SELECT * 
WHERE { 
    GRAPH <http://rdf.ebi.ac.uk/dataset/go> { 
        VALUES ?x_1 { <http://purl.obolibrary.org/obo/GO_0044727> } 
        ?x_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
        OPTIONAL { 
            ?x_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1 .?x_1_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
            OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_1 . }  
                OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2 .?x_1_1_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
                OPTIONAL { ?x_1_1_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_1 . }  
                OPTIONAL { 
                    ?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2_2 .?x_1_1_2_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
                    OPTIONAL { ?x_1_1_2_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_2_1 . }  
                    OPTIONAL { ?x_1_1_2_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_2_2 . }  
                }  
                OPTIONAL { ?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_3 . }  
            }  
            OPTIONAL { ?x_1_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_3 . }  
        }  
        OPTIONAL { ?x_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_2 . }  
        OPTIONAL { ?x_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_3 . }  
    }  
}

我尝试了@AKSW在此处通过在config.json文件中添加?force(行:"url": "http://www.ebi.ac.uk/rdf/services/sparql?force"),但它不起作用。

我认为查询可能太长了,但是当我测试查询时,它没有给出任何错误。

我发现的唯一解决方案是使用本地RDF文件查询基因本体:

  1. 我下载了go.owl文件。
  2. 使用本体转换器将其转换为乌龟。
     java -jar ont-converter.jar -i go.owl -o go_ont.ttl -of ttl -v
    
  3. 配置了HyperGraphQL:

    goconfig.json文件:

    {
        "name": "go-hgql",
        "schema": "schemas/goschema.graphql",
        "server": {
            "port": 8082,
            "graphql": "/graphql",
            "graphiql": "/graphiql"
        },
        "services": [
            {
                "id": "go-local",
                "type": "LocalModelSPARQLService",
                "filepath": "go_ont.ttl",  # <----- the TTL file
                "filetype": "TTL"
            }
        ]
    }
    

    goschema.graphql

    type __Context {
        Class:          _@href(iri: "http://www.w3.org/2002/07/owl#Class")
        id:             _@href(iri: "http://www.geneontology.org/formats/oboInOwl#id")
        label:          _@href(iri: "http://www.w3.org/2000/01/rdf-schema#label")
        subClassOf:     _@href(iri: "http://www.w3.org/2000/01/rdf-schema#subClassOf")
    }
    type Class @service(id:"go-local") {
        id: [String] @service(id:"go-local")
        label: [String] @service(id:"go-local")
        subClassOf: [Class] @service(id:"go-local")
    }
    
  4. 使用配置文件开始HyperGraphQL:

    java -jar build/libs/hypergraphql-1.0.3-exe.jar --config hgql/config/goconfig.json
    
  5. 然后执行了查询,并且没有问题的情况很好,我可以添加尽可能多的级别。

最新更新