【问题标题】:Issue with exposing the query in GRAPHQL-JAVA在 GRAPHQL-JAVA 中公开查询的问题
【发布时间】:2018-06-15 06:45:45
【问题描述】:

我是 Graphql-Java 的新手,我正在尝试将两个 *.graphqls 文件作为数组加载到架构中。每个模式都定义了单独的查询。服务器启动后,我只看到最后一个文件中的查询被公开。我的代码如下。

A.graphqls

type Query{
    queryOne(param : Param) : ResponseOne
    queryTwo(param : Param) : ResponseTwo
}

B.graphqls

type Query{
    queryThree(param : Param, param1 : Param1) : ResponseThree
}

我看到只有“queryThree”被暴露了。

我正在加载如下。

        String[] graphlList = new String[]
      {"graphqls/A.graphqls","graphqls/B.graphqls"};

        GraphQLSchema gSchema = null;
        SchemaParser schemaFile = SchemaParser.newParser()
                .files(graphlList)
                .resolvers(
                    all resolvers go here
                ).dictionary(
                        all Directory  go here
                    ).scalars(
                        all userdefined scalar defined here.
                    ).build();

            gSchema = schemaFile.makeExecutableSchema();
            return gSchema;

请指出我在哪里做错了。

【问题讨论】:

    标签: graphql graphql-java


    【解决方案1】:

    我认为您在第二个架构中缺少 extend 关键字,因此它会覆盖第一个架构中的定义。

    extend type Query{
        queryThree(param : Param, param1 : Param1) : ResponseThree
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 2018-09-02
      • 2020-05-20
      • 1970-01-01
      • 2021-12-24
      • 2016-08-23
      • 2020-09-28
      • 1970-01-01
      • 2020-04-09
      相关资源
      最近更新 更多