https://kotlinlang.org logo
Join SlackCommunities
Powered by
# graphql-kotlin
  • d

    Dariusz Kuc

    10/17/2023, 4:34 PM
    👋 I'll be presenting the
    Supercharge your GraphQL with Ktor and GraalVM
    at https://windycity.devfest.io/ (free event) next week. If you are in Chicago next Tuesday 10/24 -> stop by to say hi
    🙌 5
  • s

    S.

    11/12/2023, 12:00 AM
    Copy code
    All types within a GraphQL schema must have unique names. No two provided types may have the same name.
    No provided type may have a name which conflicts with any built in types (including Scalar and Introspection types).
    You have redefined the type 'LocalDateTime' from being a 'GraphQLScalarType' to a 'GraphQLScalarType'
    d
    • 2
    • 5
  • s

    S.

    11/13/2023, 7:37 PM
    Using the Ktor Server Plugin, where is the place to add additional types like here ?
    d
    • 2
    • 61
  • f

    Francois

    11/27/2023, 6:06 PM
    Hi team, i'm new in this channel but already used a lot the library for GraphQL especially with Federation v2. Currently i'm wondering about the possibility to pass dynamic context information from 1 service to another one. For example if i have a mutation like this: mutation createPolicy($policy: PolicyCreateParamsInput!, $participants: [Int!]!) { createPolicy(policy:$policy) { policyId productId dynamic, }, createParticipants(participantId: $participants), }
    s
    • 2
    • 3
  • f

    Francois

    11/27/2023, 6:07 PM
    I'm looking to send additional information from the first mutation function to the second call
  • s

    skennedy

    12/29/2023, 6:26 PM
    The 7.0.2 Gradle plugin is pulling in a vulnerable version of Jackson (2.15.2), and I'm really struggling to use dependency constraints to force that to a newer one (it works for real project dependencies, but I haven't been able to get it working for the GraphQL Kotlin Gradle plugin). Anyone know how to force that constraint, or if there's a plan to release a new version of the plugin that depends on a newer version of Jackson?
    s
    d
    t
    • 4
    • 6
  • d

    Dariusz Kuc

    03/06/2024, 8:29 PM
    👋 I'll be presenting at the ApiDays NYC 04/30-05/01. If you are around stop by to say hi! *and yes their website is pretty weird as they update different sections at different times (so it still shows some of the 2023 and some of the 2024 content)
    👏 4
  • m

    Mitchell Syer

    03/10/2024, 11:04 PM
    With DataLoaders, is there a way to limit the fetched data based on a outside value like a user id?
    d
    • 2
    • 13
  • d

    dany giguere

    03/12/2024, 10:56 PM
    What is the best graphql library to use with Kotlin’s coroutines ? my demo project is here: https://github.com/danygiguere/spring-boot-3-reactive-with-kotlin-coroutines but I use only coroutines with suspend functions like:
    Copy code
    @GetMapping("/posts/{id}")
    suspend fun getById(@PathVariable id: Long): ResponseEntity<PostDto> {
        val response = postService.findById(id)
        return if (response != null) ResponseEntity.ok(response)
        else ResponseEntity.notFound().build()
    }
    I’d like to convert the project to use GraphQl. (it will be in a different demo of course with a bff and microservices)
    a
    s
    +2
    • 5
    • 10
  • m

    Mitja Debeljak

    04/04/2024, 11:41 AM
    Hello. I am trying to add exposed to my ktor server with graphql-kotlin, fetch data from a database and use it with graal-vm. I followed the supercharged-graphql example and it all works untill I tried to use a class that inherits from org.jetbrains.exposed.dao.IntEntity. Looks like this:
    Copy code
    object ProductTable : IntIdTable() {
        val name = varchar("name", 80)
        val price = double("price")
    }
    
    class ProductEntity(id: EntityID<Int>) : IntEntity(id) {
        companion object : IntEntityClass<ProductEntity>(ProductTable)
    
        var name by ProductTable.name
        var price by ProductTable.price
    }
    ...
    class ProductQuery : Query {
      private val repository = ProductRepository()
      suspend fun products(): List<Product> = repository.findAll()
    }
    ...
    class ProductRepository {
      suspend fun findAll(): List<Product> = query {
        val products = ProductEntity.all().map { entityToProduct(it) }
    
        products
      }
    }
    When I build a native image and run it against a query that is calling this oblect, I get this error:
    kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor ProductEntity(id: org.jetbrains.exposed.dao.id.EntityID<<http://kotlin.Int|kotlin.Int>>) defined in si.schlamberger.climbholds.db.product.ProductEntity[DeserializedClassConstructorDescriptor@733818e6] (member = null)
    d
    • 2
    • 5
  • m

    Mitja Debeljak

    04/04/2024, 11:42 AM
    Tried to add:
    Copy code
    typeHierarchy = mapOf(
            IntEntity::class to listOf(ProductEntity::class),
            IntIdTable::class to listOf(ProductTable::class)
          )
    but does not help. I probably do not understand enough how reflection work, to define this correctly.
  • a

    Aman Agarwal

    04/14/2024, 3:07 AM
    Hi Team, I am trying to introduce new annotation
    @GraphQLInputName
    which is expected to override the default behaviour of appending
    Input
    as suffix in the input classes. Here is the changes which I have made https://github.com/ExpediaGroup/graphql-kotlin/pull/1949/files I am trying to test these changes in one of my service where I have generated the jar
    graphql-kotlin-schema-generator
    and updated it's generated version into my pom, I have written the test cases those are working as expected but when I am applying this annotation in service my
    schema.graphql
    is not showing the changes as expected. Could you please help to know what I am missing?
    s
    • 2
    • 4
  • a

    Aman Agarwal

    04/16/2024, 5:46 PM
    Hi Team, I am trying to test the
    graphql-kotlin-maven-plugin
    locally, I build it's jar and installed it into local maven and updated the version in my service but getting below error
    Copy code
    Execution default of goal com.expediagroup:graphql-kotlin-maven-plugin:8.0.0-SNAPSHOT:generate-sdl failed: A required class was missing while executing com.expediagroup:graphql-kotlin-maven-plugin:8.0.0-SNAPSHOT:generate-sdl: kotlin/jvm/functions/Function0
    [ERROR] -----------------------------------------------------
    [ERROR] realm =    plugin>com.expediagroup:graphql-kotlin-maven-plugin:8.0.0-SNAPSHOT
    [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
    [ERROR] urls[0] = file:/Users/amaagarwal/.m2/repository/com/expediagroup/graphql-kotlin-maven-plugin/8.0.0-SNAPSHOT/graphql-kotlin-maven-plugin-8.0.0-SNAPSHOT.jar
    [ERROR] Number of foreign imports: 1
    Can someone help, if there is another way to test it?
    d
    s
    • 3
    • 41
  • d

    Dušan Salay

    05/02/2024, 9:15 AM
    Hi 👋, I would like to use graphql-kotlin client. So I need to generate all query classes from schema.graphql file. I tried to use
    graphqlGenerateClient
    gradle task. I set all required properties:
    Copy code
    val graphqlGenerateClient by tasks.getting(GraphQLGenerateClientTask::class) {
        packageName.set("org.harmonelo.moneys4.graphql")
        schemaFile.set(file("${project.projectDir}/src/main/resources/schema.graphql"))
    }
    task run ends up successful ✅ but I don’t see any generated classes. Only what I spotted is empty folder in build folder: (attached img) Can you pls give me advise what am I doing wrong? 🙉
    solved 2
    d
    • 2
    • 5
  • d

    Dariusz Kuc

    05/07/2024, 2:57 PM
    Hello 👋 While sadly it will take a while for the final v8 release* (we need to wait for a new version of
    graphql-java
    that has a required fix and is currently targeting june/july timeframe) -> if you are interested in testing stuff out, we just dropped a new version that uses patched version of
    graphql-java
    v22 which should bring some nice perf improvements (v22 no longer needs to wrap everything in completable futures). Check it out -> https://github.com/ExpediaGroup/graphql-kotlin/releases/tag/8.0.0-alpha.1 *we'll most likely do some other cleanups around deprecated stuff
    🙌 2
  • d

    Dušan Salay

    06/06/2024, 6:35 AM
    Hi, I am using graphql-kotlin client. I am having issue with parsing this graphql response which sadly has non standart UpperCases of attributes:
    Copy code
    {
      "Data": {
        "CreateIssuedInvoice": {
          "ID": "62d0e9c6-1c54-4324-8ac5-716701b325be",
          "Stav": 0,
          "CisloDokladu": "240010989"
        }
      },
      "Status": 1,
      "Message": "",
      "StackTrace": ""
    }
    but default deserialisation of
    GraphQLWebClient
    is unable to parse it. I assume that’s is because of first uppercase letter? Is here any possible workaround how to fix that?
    d
    • 2
    • 14
  • s

    S.

    07/29/2024, 9:18 AM
    why does
    query {sessions(dateRange: {range: "2024-06-28/2024-07-28"})}
    work, but if I use a variable instead
    query ($dateRange: DateRangeInput) {sessions(dateRange: $dateRange)}
    ( with
    "dateRange": {"range": "2024-06-28/2024-07-28"}
    ) it does not?
    m
    d
    • 3
    • 4
  • t

    Thomas Bakker

    07/31/2024, 12:03 PM
    Hi, are there plans to support Spring MVC in the future? I found some old threads dating to 2021 saying there were plans for integrating
    spring-graphql
    to allow MVC support, but can’t find anything recent. We have an old project that’s based on Spring Boot 2.4 (MVC) and graphql-kotlin 2.1 that I’m trying to upgrade. Or maybe someone has experience integrating the library (or schema generator) with an MVC project 🙂
    s
    d
    • 3
    • 3
  • d

    Dariusz Kuc

    09/09/2024, 9:03 PM
    👋 it is indeed a coroutine question 🙂 TLDR its all about switching threads
    Copy code
    1 MDC.put("k1", "v1")
    2 <http://logger.info|logger.info>("one")
    3 withContext(<http://Dispatchers.IO|Dispatchers.IO> + MDCContext()) {
    4   MDC.put("k2", "v2")
    5   <http://logger.info|logger.info>("two")
    6   delay(10000) // Fake an API call
    7   <http://logger.info|logger.info>("three")
    8 }
    9 <http://logger.info|logger.info>("four")
    given the above I believe the behavior would be - • when calling the function we got initial MDC value • lines 1&2 will run on the same thread with updated MDC
    { "k1": "v1" }
    • then at line 3 we start the coroutine which MAY change the thread • our MDC context of this coroutine is
    { "k1": "v1" }
    • 4 & 5 will run on the same thread with modified MDC
    { "k1": "v1", "k2": "v2" }
    • 6 is suspendable call and once it returns it may resume on a different thread • 7 resets the MDC back to
    { "k1": "v1" }
    (from line 3) • we are back to main logic where we may run on a different thread which then uses MDC context from when we entered the function (i.e. initial MDC) and yes in order to have consistent logging behavior you would have to restore the MDC after each suspension point see the docs -> https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-slf4j/kotlinx.coroutines.slf4j/-m-d-c-context/
    o
    • 2
    • 5
  • s

    S.

    11/11/2024, 11:45 AM
    Ktor 3.0.1 PR https://github.com/ExpediaGroup/graphql-kotlin/pull/2055
    s
    d
    +2
    • 5
    • 22
  • a

    ade

    01/15/2025, 10:21 AM
    Hi and thanks for the nice software. I've started to randomly get an error when making requests from my cmp client (desktop apollo kotlin). The server throws an error, "Unknown operation named '<my operation name>'". I've tracked it down to graphql-java here: https://github.com/graphql-java/graphql-java/blob/5ce0eadb434848910cb417c646cfd30b8e75a72b/src/main/java/graphql/language/NodeUtil.java#L84 It will happen typically in the first few requests when starting the client. When I try again a second later it works and doesn't seem to happen again, so perhaps it's client related... The server is not restarted between and is always running. What could be causing that?
    m
    • 2
    • 32
  • a

    abhinandan chivate

    01/22/2025, 4:44 AM
    graphql federation micro service based example where I want to retrieve the details of orders along with products and user details .
    s
    • 2
    • 2
  • p

    Preetam

    02/16/2025, 12:50 AM
    Hello, I successfully configured subscriptions to work on server using
    graphql-kotlin-ktor-server
    lib, and I get the updates successfully in graphiql console. but when I try to use subscriptions on client using apollo client, I don't get any data I tried using both
    <ws://localhost:4000/graphql>
    and
    <ws://localhost:4000/subscriptions>
    when I try to connect using
    wscat -c <ws://localhost:4000/subscriptions>
    I get
    error: Unexpected server response: 400
    I have followed this https://www.apollographql.com/tutorials/apollo-kotlin-android-part2/08-subscriptions with no success.
  • j

    Joe

    04/15/2025, 6:01 PM
    8.6.0 release notes:
    Copy code
    IMPORTANT
    
    see <https://github.com/ExpediaGroup/graphql-kotlin/releases/tag/8.3.0>
    but that leads to a 404? looks like some of the post 8.2.1 tags are now relabeled as 9.0.0-alpha.x releases but unclear as a consumer what's actually happening?
  • p

    phldavies

    04/15/2025, 6:09 PM
    It looks like 8.6.0 reverts all the changes since 8.2.1, support for ktor 3.x, kotlin 2.x etc
  • s

    Samuel Vazquez

    04/15/2025, 6:36 PM
    Thats my bad, i made a mistake when releasing graphql-kotlin 8.3.0 -- that should've been a breaking change (ktor 3, kotlin 2), i was supposed to do a mayor release. To avoid doing bunch of reverts, I decided to start with alpha releases for v9 this is the mapping i had to do in github 8.3.0 -> 9.0.0-alpha.1 8.4.0 -> 9.0.0-alpha.2 8.5.0 -> 9.0.0-alpha.3 8.6.0 is now the latest release from 8.x.x branch and 9.0.0-alpha.4 is the latest release from master/main branch apologizes for the miss understanding and the inconveniences
    👍 1
  • s

    Samuel Vazquez

    04/15/2025, 6:41 PM
    having said that, if you are using v9 or v8 try latest versions, we found a very bad memory leak with property data fetchers being instantiated by property by graphql operation, so we are using a singleton now, more info in release notes.
    👍 1
  • p

    phldavies

    04/15/2025, 6:43 PM
    any reason not to release 9.0.0 soon(ish)?
  • s

    Samuel Vazquez

    04/15/2025, 6:44 PM
    i still need to work on updating to graphql-java 23, once done ill release 9.0.0, for now you can try 9.0.0-alpha.4
    👌 1
  • l

    Lucas Fugisawa

    04/17/2025, 11:30 PM
    Hi everyone! We currently have a service running on Kotlin 2.0, JVM 11, with Ktor 2 and graphql-kotlin 5.3.2. We're planning to upgrade our tech stack soon, potentially moving to Kotlin 2.1, JVM 21, Ktor 3, and the latest available version of graphql-kotlin (currently 8.6.0, but hopefully 9 if it’s out by then). We're thinking of starting with the JVM upgrade, which seems to be the most straightforward step with no major compatibility issues so far. After that, do you have any recommendations for the upgrade path to Ktor 3 and graphql-kotlin? Any advice, tips, or lessons learned would be super helpful and much appreciated! Thanks a lot in advance! 🙏
    ☝️ 1