0

Is it possible an object with arguments? In other words, can I create an object for running queries like this?

{
    artifact(group: "com.graphql-java", name: "graphql-java") {
        group
        name
        version
    }
}

If yes, how?

I couldn't find a method for creating arguments in graphql.schema.GraphQLObjectType.newObject.

4

2 回答 2

0

调用field()Builder添加参数。

于 2017-01-09T12:45:19.910 回答
0

您可以使用graphql-java-annotations并以非常简单的方式定义它:

@GraphQLName("Query")
class Query {

    @GraphQLField
    static List<Item> items(DataFetchingEnvironment environment) {
        // Fetch all
    }

    @GraphQLField
    static Item item(DataFetchingEnvironment environment, @GraphQLName("id") String id) {
        // Fetch using the "id" argument
    }
}
于 2017-07-24T14:30:58.450 回答