Search code examples
graphqlgraphql-java

Issue with exposing the query in GRAPHQL-JAVA


I am Newbie to Graphql-Java, I am trying to load two *.graphqls file as array in to schema. Each schema has separate query defined. After server startup, I see only the query in last file got exposed. My code below.

A.graphqls

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

B.graphqls

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

I see only "queryThree" got exposed.

I am loading like below.

        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;

Please highlight, where I am making wrong.


Solution

  • I think you're missing the extend keyword in the second schema, so it overrides the definition from the first.

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