简体   繁体   中英

Define more than one type of query GraphQL Schema - Best approach to define different types on query one one object

Is this possible to specify more than one type of query in one schema?

type Query {
    productsByRegion(match : String) : [Product]
    productsByType(match : String) : [Product]
}

type Product {
    id: ID
    name: String
}

Expected queries which can be fired using single schema definition:

{
    productsByRegion {
        id
        name
    }
}

{
    productsByType {
        id
        name
    }
}

GraphQL java implementation cached some data. After server, restart both the query works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM