https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
graphql-kotlin
  • m

    manlan

    08/25/2020, 5:23 PM
    Please, can somebody guide me in creating a Ktor server using graphql-kotlin? If there's a way in the first place?
    d
    • 2
    • 5
  • h

    herder

    08/27/2020, 5:55 AM
    Hey, I'm trying to inspect the request when creating a
    GraphQLContext
    to be able to customize a callout to an external service, but I can't find how to get hold of the actual query body from the request? Is there a way to get hold of the raw query when creating my context?
    d
    s
    • 3
    • 20
  • s

    Saharath Kleips

    08/27/2020, 5:51 PM
    Hi there, does anyone know how I would go about grabbing the requested fields that are from a fragment? I’ve looked into the
    DataFetchingEnvironment.selectionSet.definitions
    object which seems to be what I want (or at least partially), but it doesn’t appear to contain fields requested from fragments.
    d
    • 2
    • 3
  • l

    Lenny

    08/28/2020, 12:56 AM
    i found a way to make a dataloader implementation for graphql-kotlin that allows using suspended functions (based on an approach proposed by apollo) https://gist.github.com/lennyburdette/f3fe6ae7a498698774cc95d1bfc956b4 … would love some review/opinions!
    s
    d
    j
    • 4
    • 12
  • h

    Hector Gonzalez

    09/15/2020, 7:30 PM
    Hi everyone! I am currently working on implementing custom error handling and logging using GraphQl and Kotlin on a federated service. Does anyone have a current example on how to do this? The examples I've found online seem to use deprecated classes.
    d
    • 2
    • 14
  • t

    tim

    09/16/2020, 1:08 PM
    Hi, has anyone managed to add an Option<T> as a scalar for graphql?
    d
    • 2
    • 3
  • r

    Robert

    09/22/2020, 4:39 PM
    How is the Caching / eTag Support for the Library? If I use Apollo Client on the Frontend, would I benefit from caching?
    d
    m
    • 3
    • 12
  • d

    Dusan Hornik

    09/23/2020, 1:09 PM
    Hello, thank you for the great library. I am trying to cache some database calls on per request basis. I thought I could use Spring components with @RequestScope, however that doesn’t seem to be supported with Reactive Stack. Do you have any recommendations on what to use instead?
    d
    • 2
    • 1
  • d

    Das135

    09/30/2020, 9:57 AM
    Hi. Does GraphQL kotlin preserve order of certain functions send in one graphql request? I have something like this:
    mutation {
      deleteObj1(where){
        affectedRows
      }
    
      deleteObj2(where){
        affectedRows
      }
    
      deleteObj3(where){
        affectedRows
      }
    
      deleteObj4(where){
        affectedRows
      }
    }
    If order of executed functions will change, there can be thrown foreign key constraint condition -> I need to execute mutations like DELETE CASCADE...
    l
    d
    c
    • 4
    • 5
  • l

    Lenny

    10/15/2020, 6:21 PM
    hi folks, jeff from apollo tells me y’all (the expedia team) have figured out a way to check the generated SDL into source control that reflects changes to your kotlin classes — is that true? how does it work?
    d
    j
    • 3
    • 11
  • h

    huehnerlady

    10/16/2020, 1:31 PM
    Hi, We want to introduce a Kotlin Service with GraphQL now. Currently our whole ecosystem is WebMVC. I saw that graphql-kotlin supports WebFlux exclusively at the moment. Is there a plan to change that, eg. to extract functionality to enable others to choose which eco system they wanna use? Many thanks
    d
    • 2
    • 1
  • d

    Dusan Hornik

    10/19/2020, 10:42 AM
    Hi is there a way to disable adding “Input” suffix for Graphql input types?
    d
    • 2
    • 7
  • h

    huehnerlady

    10/20/2020, 2:11 PM
    Hi, We are now using a compromise to the starter, we use the graphql-kotlin-schema-generator. So far it works well. We use Type Aliases for BigDecimal to make it clearer what it actually is (percent/euro). How do I get these typeAliases as Scalars into the schema? I saw this page explains custom scalars very nicely. BUT I was wondering if it would be possible to reuse the scalar that seems to exist for BigDecimal already? At least the mapping seems to work, but in the schema it says just BigDecimal, even if we have the typealiases in place.
    ☑️ 1
    d
    d
    • 3
    • 14
  • d

    Das135

    10/21/2020, 7:43 AM
    Hello! Is there any way to add Kotlin extension functions to schema generation? I have read some issues related to my question - if I understand correctly, graphql kotlin does not provide special funcionality for generating extension functions. But is there any workaround for this?
    data class First(
          val id: Long,
          val name: String
    ) {
       fun second(env: DataFetchingEnvironment): Second {
          //query second class
       }
    }
    
    fun First.another(env: DataFetchingEnvironment): Another {
    // I need this function to be seen in graphql schema and resolver
    }
    d
    • 2
    • 2
  • n

    Nikky

    11/03/2020, 11:02 PM
    so.. we are using a shared project for the data classes, use those from graphql sping server and i wrote a few lines for doing the requests using kotlinx-serialization and ktor-client i would like to also use kotlinx-serialization on the server, is there such a project .. or where can i help to make that happen ?
    d
    s
    • 3
    • 4
  • m

    Martin Brehovsky

    11/03/2020, 11:36 PM
    I’m experimenting with graphq-kotlin and I wonder if it possible to get a response which combines errors and data. Currently when any of my data fetcher fails, the whole response fails and there is no
    data
    section in the response, only
    errors
    . Is it possible to get a response which would give me values for fetcher who did not fail and errors for the fetchers which fail? Something like this:
    {
        "data": {
            "item": {
                "foo": "foo"
            },
        }
        "errors": [
            {
                "message": "Exception while fetching data (error) : I wonder what happends",
                "locations": [
                    {
                        "line": 5,
                        "column": 3
                    }
                ],
                "path": [
                    "bar"
                ],
                "extensions": {}
            }
        ]
    }
    s
    • 2
    • 8
  • m

    Martin Brehovsky

    11/03/2020, 11:44 PM
    Another question - is it possible to specify additional extensions in the response? We are thinking about exposing some additional metadata with the response and the extensions field seems to be the right fit for this. Is there a way to send the extensions with the responses coming from the server?
    s
    j
    • 3
    • 4
  • h

    huehnerlady

    11/09/2020, 12:35 PM
    Hi, We are having a problem implementing a separate data fetcher for a property. This documentation says to use a function instead of a property for that. How would you do this using spring beans in a spring-MVC environment? As this is a POJO still you cannot really inject any repote clients here. Any ideas how we can achieve what we wanna do?
    ☑️ 1
    s
    d
    • 3
    • 7
  • m

    Martin Brehovsky

    11/11/2020, 12:55 AM
    Hey guys, I have a question regarding requesting non-existing fields. Currently when I ask for a field which does not exist in the schema, the whole query fails, but I wonder if it would be somehow possible to return the other fields which are valid and return errors (in the errors field) only for the fields which do not exists in the schema.
    l
    d
    s
    • 4
    • 14
  • m

    Martin Brehovsky

    11/14/2020, 2:37 AM
    Is there any recommendation when it comes to publishing the schema? I’m running kotlin-graphql in spring and I’m wondering what would be the best way to integrate the schema exposed by this service with Apollo Studio? Pretty much what I’m looking for is an ability to generate the schema to a file and then upload it to Apollo Studio. Ideally all this happening in our CI build ..
    d
    m
    • 3
    • 6
  • d

    David Glasser

    11/18/2020, 7:37 PM
    I’m investigating porting our existing Kotlin graphql server to graphql-kotlin. One thing I’m not quite clear on from docs — I see that you specify packages to scan for classes, but how does that relate to providing root types? eg, if a type in one of the packages references (arguments, return type, etc) a type from a faraway package, will that type be processed into the schema too, or not? and do all types in the specified packages get treated as graphql types by default, or only those reachable from the root types?
    s
    • 2
    • 2
  • m

    Martin Brehovsky

    12/01/2020, 3:10 AM
    Is there a way to use generic types with the schema generator? What I’m looking for is being able to define an abstract class with a generic type and make it “excluded” from the schema, but still expose the functions defined by the interface in the schema together with the resolved type at the use time. Something like this:
    abstract class Page<T:Any> {
       @GraphQLIgnore
       abstract fetchItems() ... 
    
       // these will be exposed in the schema
       fun itemsCount(): Int
       fun hasNextPage(): Boolean
       fun pageItems: List<T>
    }
    
    class PageOfStrings: Page<String> {
       override fetchItems() ... 
    }
    
    class PageOfInts Page<Int> {
       override fetchItems() ... 
    }
    The resulting schema would have two types:
    type PageOfStrings {
       itemsCount: Int!
       hasNextPage: Boolean!
       pageItems: [String]!
    }
    
    type PageOfInts {
       itemsCount: Int!
       hasNextPage: Boolean!
       pageItems: [Int]!
    }
    Is something like this doable?
    d
    s
    • 3
    • 5
  • p

    pcarrier

    12/01/2020, 5:11 AM
    Hi! Trying graphql-kotlin for the first time with 3.6.8 and 4.0.0-alpha.7 for a small control plane, and running into trouble with:
    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
    sealed class Command {
    	@JsonTypeName("ResetCursorPosition")
    	data class ResetCursorPosition(
    		val dataSource: String, val position: Instant
    	) : Command()
    }
    which causes a failure in
    assertTypeUniqueness
    ; might I be missing some semi-obvious gotchas with the current implementation? Is it worth trying to minimize to a reproduction case? Otherwise the DX has been great so far.
    s
    • 2
    • 2
  • a

    Anders Kirkeby

    12/02/2020, 2:02 PM
    Hi. I’m trying to add a conversion from Set<*> to a GraphQLList. I know it is not inherently supported in GQL but the backing data is read-only and has already been implemented using sets. For simplicity lets say we have:
    data class TestClass(
       val content: Set<String>
    )
    to remedy this, I’ve added a Hook with the following SchemaGeneratorHooks#willGenerateGrpahQLType method:
    @ExperimentalStdlibApi
    override fun willGenerateGraphQLType(type: KType): GraphQLType? = when {
        type.isSubtypeOf(typeOf<Set<*>?>()) -> {
            type.arguments.first().type?.let { kType ->
                val typeRef = (kType.classifier as KClass<*>)
                GraphQLList.list(GraphQLTypeReference.typeRef(typeRef.simpleName))
            }
        }
        else -> null
    }
    this works when creating a query that returns TestClass or List<TestClass>. However, when creating a Query that returns a Set<TestClass> it fails as the TestClass reference has not yet been created. From what I could gather, this method should just create the reference to
    TestClass::class.simpleName
    and the generator should generate the class in “due-time” which should lead to Set<TestClass> resolving as a GQLList<TestClass> in the playground, or am I missing something?
    d
    • 2
    • 26
  • m

    Mattlangsenkamp

    12/12/2020, 7:05 AM
    I am trying to accomplish authentication with JWTs. here: https://github.com/ExpediaGroup/graphql-kotlin/discussions/663In it was advised to do some JWT validation work in a spring webfilter and then store that is the security context and pick that up in the GraphQl context. Is this totally necessary or could all the JWT validation logic just be dont in the GraphQLContextFactory generateContext function, as we have access to headers there?
    s
    r
    • 3
    • 4
  • c

    Chris Wicks

    12/15/2020, 4:17 PM
    Hey, there! I'm trying to incorporate graphql-kotlin into an existing spring boot rest application with starter-security, starter-web, etc. I'm wondering if there's any special configuration or caveats I should know about? I've created a few root-level queries, and the schema generation works as expected, but the /graphql endpoint isn't working (404), nor is the playground.
    s
    d
    • 3
    • 12
  • n

    Nikky

    01/12/2021, 1:53 PM
    him we are trying to add subscription (now that we got websockets to go through the google cloudrun) and it seems we are running into a few weird issues whenever there is any issues (syntax or such) it returns
    {
      "error": "Could not connect to websocket endpoint <ws://localhost:8080/subscriptions>. Please check if the endpoint url is correct."
    }
    not sure if this is a issue in plaground or in the library however and seems like the
    GraphQLContextFactory
    does not kick in for subscriptions so we cannot figure out how to get access to Header
    Authorization
    for subscriptions currently
    d
    j
    s
    • 4
    • 30
  • h

    herder

    01/12/2021, 3:39 PM
    Hey, I'm trying to register a
    FederatedTypeResolver
    in a Boot applications, but how ever I do it I can't get it to kick in. I wonder if I'm misunderstanding somehing - I have a simple schema like this
    @KeyDirective(FieldSet("id"))
    data class MySubThing(val id: Int?, val extraThing: String)
    
    data class MyThing(@ExtendsDirective val id: String, val subThings: List<MySubThing>) {
    }
    , and register this resolver class as a bean:
    class MySubThingResolver: FederatedTypeResolver<MySubThing> {
        override suspend fun resolve(
          environment: DataFetchingEnvironment,
          representations: List<Map<String, Any>>
        ): List<MySubThing?> {
          return representations.stream().map {
            MySubThing(it["id"]?.toString()?.toInt(), "WOOOP")
          }.collect(Collectors.toList())
        }
    But I can't get the resolver to be called however I try. What is the recommended way of registering resolvers for a schema in a Boot app? (I have set the
    graphql.federation.enabled
    to
    true
    )
    d
    • 2
    • 14
  • j

    Jilles van Gurp

    01/14/2021, 7:05 PM
    This page (https://expediagroup.github.io/graphql-kotlin/docs/schema-generator/writing-schemas/interfaces) suggests it should be possible to use sealed classes in our generated schema. However, I’ve not been able to make this work for us. Is this known broken in the current 4.0 alpa11 or is there something I’m missing here? I’m trying to add a field to one of our input types that is a simple sealed class. As soon as I do that, I get this error:
    Caused by: com.expediagroup.graphql.exceptions.CouldNotCastGraphQLSchemaElement: Could not cast GraphQLSchemaElement GraphQLInterfaceType{name='GeoJsonGeometry', description='null', fieldDefinitionsByName=[type], typeResolver=null} to class graphql.schema.GraphQLInputType
    This is the sealed class
    sealed class GeoJsonGeometry(val type: GeometryType) {
        class Point(type: GeometryType = GeometryType.Point): GeoJsonGeometry(type)
        class Polygon(type: GeometryType = GeometryType.Polygon): GeoJsonGeometry(type)
    }
    Simply adding a
    val geometry: GeoJsonGeometry?=null
    to our input date class breaks it, removing that fixes it.
    s
    • 2
    • 3
  • j

    Joe

    01/15/2021, 9:15 PM
    Any work (or even just thinking) been done on subscription protocol migration from https://github.com/apollographql/subscriptions-transport-ws to https://github.com/enisdenjo/graphql-ws ?
    d
    s
    • 3
    • 2
Powered by Linen
Title
j

Joe

01/15/2021, 9:15 PM
Any work (or even just thinking) been done on subscription protocol migration from https://github.com/apollographql/subscriptions-transport-ws to https://github.com/enisdenjo/graphql-ws ?
d

Dariusz Kuc

01/15/2021, 9:39 PM
afaik it is not anywhere on our roadmap i'd recommend to open up an issue on the repo to track it
s

Shane Myrick

01/15/2021, 9:50 PM
With the latest changes in 4.0.0-alpha.11 you can implement your own server on top of some standard interfaces so if you wanted to expose
/graphql
over WS instead of standard http you can create your own
graphql-kotlin-*-server
implementation
View count: 1