ExpediaGroup / graphql-kotlin

Libraries for running GraphQL in Kotlin

Home Page:https://opensource.expediagroup.com/graphql-kotlin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't generate client when schema includes Query using `extend` keyword

konnik opened this issue · comments

Library Version
6.5.5

Describe the bug

The generator does not seem to work with schemas using extend keyword.

Some more context: we are designing an rather big graphql API using the "schema first" approach and have split up the schema in multiple files for different parts of the API. That means that we add fields to the Query type using extend Query in different files.

To test the API we want to use a generated client from this schema files. First we combine all the separate files into one big schema from which we try to generate the client. This does not seem to work though.

Btw, is there a way to configure the plugin to specify a directory of schema files rather than just one single one? Then we would not have to join them "manually" in the build script.

To Reproduce

Schema:

type Query {
    _empty : String
}

extend type Query {
    korvar(id: KorvId =  null, namn: String = null) : [Korv!]!
}


type Korv {
    id : KorvId!
    namn : String!
}

type Mutation {
    nyKorv(namn: String!) : Korv!
    raderaKorv(id: KorvId!) : Korv
}

scalar KorvId

Query:

query HamtaKorv($id: KorvId = null, $namn : String = null) {
    allaKorvar: korvar {
        id
        namn
    }
    filtreradeKorvar: korvar(id: $id, namn: $namn) {
        id
        namn
    }
}

Gives error:

Execution failed for task ':graphqlGenerateTestClient'.
> There was a failure while executing work items
   > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.GenerateClientAction
      > Operation HamtaKorv specifies invalid selection set for Query - cannot find field 'korvar'

Expected behavior

The client-generation should succeed.

Closing as duplicate of #1485

TLDR It is a good use case and client library should support it but currently I won't have time to work on it. PRs are always welcome though!