在GRAPHQL-JAVA

时间:2018-01-05 12:42:09

标签: graphql graphql-java

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

请突出显示,我在哪里做错了。

1 个答案:

答案 0 :(得分:2)

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

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