在 GRAPHQL-JAVA 中公开查询的问题

Issue with exposing the query in GRAPHQL-JAVA

我是 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;

请高亮,我哪里做错了。

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

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