https://kotlinlang.org logo
Docs
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

    Maria Sharkina

    10/23/2021, 11:24 PM
    Hey all. I am writing integration/functional tests for our graphql endpoint using
    WebTestClient
    . I configured it to
    .accept(MediaType.APPLICATION_JSON)
    .contentType(MediaType.APPLICATION_JSON)
    I read our test queries and mutations from .graphql files in our Recource directory, massage them to a proper json format (adding "query key and variables), and all worked fine until I got a mutation which has input type like this :
    mutation {
        addConsumerAddress(data : {
            address : "Address location."
            setDefault: true
        }) {
            id
        }
    }
    I can perfectly run this mutation from postman and my mobile clients, but ``WebTestClient` always return
    Bad request 400
    error. I solved this by changing setting of webtest client to accept content type graphql
    .contentType(MediaType("application", "graphql"))
    and passing not formatted String, basically plain .gpaphql file content :
    mutation {
        addConsumerAddress(data : {
            address : "Address location."
            setDefault: true
        }) {
            id
        }
    }
    But just wondering if anyone know what's wrong with MediaType. APPLICATION_JSON or this mutation?
    d
    • 2
    • 6
  • j

    Joe

    10/29/2021, 6:40 PM
    Anyone already thought about the new GraphQLContext map and type-safe context storage? We currently have a context object with some well defined/typed properties; moving to a string key + a cast of the returned value feels like a step back even though it'd probably be fine. Possibly extensions to GraphQLContext for these well defined properties might make sense, but haven't fully thought this through yet, so wondering if others had?
    d
    s
    • 3
    • 6
  • h

    hamid

    11/17/2021, 9:43 AM
    I'm trying to upgrade graphql-kotlin lib from 3.x.x to 5.x.x in our project and I faced a problem in subscription authentication. We used JWT token authentication in the header of websocket request and it worked fine before. But it failed after upgrading to 5.x.x. I did some research and found your example. Then I implemented a
    SpringSubscriptionGraphQLContextFactory
    but this didn't work too because there is no security context available there. I tried
    coroutineContext[ReactorContext]
    and
    ReactiveSecurityContextHolder.getContext()
    but both of them returns null. My question is how can I get the
    SecurityContext
    in this context factory and populate it in
    GraphqlContext
    because it is needed for authorisation in our
    AuthorizationDataFetcher
    ?
    n
    s
    • 3
    • 6
  • m

    Martin Brehovsky

    11/23/2021, 2:11 AM
    A quick question - is it possible to use Kotlin interface and represent it as GraphQL Type? I have some generics constraints which require me to use interface in the Kotlin world, but need to expose it as Type in GraphQL world. Is something like this doable?
    d
    s
    • 3
    • 11
  • e

    Eamonn

    11/30/2021, 3:35 PM
    Hello experts. The graphql-kotlin project looks great to me, but one tiny point in the ktor example was unclear. In the dataloaders, the entities are searched for based on a set of ids
    Book.search(ids.flatten())
    , and the resulting list is then filtered for only those that match that same set of ids
    allBooks.filter { idSet.contains(it.id) }
    . Is that filter not superfluous? Thanks, Eamonn https://github.com/ExpediaGroup/graphql-kotlin/blob/master/examples/server/ktor-se[…]aphql/examples/server/ktor/schema/dataloaders/BookDataLoader.kt
    s
    • 2
    • 1
  • e

    Eamonn

    12/02/2021, 9:39 AM
    I wonder if the SpringGraphQLContextFactory needs some finesse. It currently requires us to implement the deprecated
    override
    suspend
    _fun_ generateContext(request: ServerRequest)
    while leaving the new
    suspend fun generateContextMap(request: ServerRequest): Map<*, Any>?
    optional. I wonder if it should not be the other way around - or for backwards compatibility give them both default implementations. Also in the documentation for Generating GraphQL Context in spring server, the examples are for the deprecated method. To me, as a newcommer, it's a little confusing - just my little bit of feedback. Keep up the good work!
    d
    • 2
    • 2
  • n

    Neal Sanche

    12/09/2021, 9:44 PM
    I have another question about graphql context factory. Is there a way to know the lifecycle of the produced context? For example I'd like to know when it might be safe to destroy some things that are built as part of the context. Maybe I shouldn't be putting things that need to be cleaned up into the context. I'll keep looking...
    d
    • 2
    • 3
  • j

    Jared Rieger

    12/14/2021, 12:31 PM
    Hey all, I have a question regarding Graphql versioning for fields. Does the library support this? Is there something that already exists that should be used instead?
    👀 1
    d
    s
    b
    • 4
    • 9
  • k

    Kanu

    12/18/2021, 2:24 AM
    Seen plenty of discussions regarding GraphqlContext. Maybe it has been discussed plenty of times (will appreciate links to existing threads) but what is the best way to expose request scoped graphqlContext as a Spring bean in webflux reactive app with coroutines? Of course the option of bypassing it from graphql layer to all the services, repositories, etc works fine. But it makes the code more verbose and harder to maintain. Thanks
    s
    • 2
    • 3
  • f

    Filip Lastic

    12/20/2021, 7:15 PM
    Hi! Please, any tips what is the best way how to run and debug maven/gradle plugin task
    graphqlGenerateClient
    during development in your lib? 🙂
    d
    • 2
    • 4
  • k

    Kanu

    12/21/2021, 12:03 AM
    Hi everyone, trying to migrate from v3 to v5 of expedia-graphql. Having exactly the same issue as in https://github.com/ExpediaGroup/graphql-kotlin/discussions/1095 The problem is we have a flow: in graphql request we create a user and generate JWT token. Then we need to set it into HTTP response header. Currently we do it via http response that we have in graphql context. SO I'm trying to move that logic to Webfilter. But the issue is that in Webfilter the http response is already committed after calling the controllers. So I cannot set the header (https://stackoverflow.com/questions/32829124/adding-header-in-response-in-filter) Any suggestions how to overcome that?
    s
    • 2
    • 2
  • k

    Kanu

    12/22/2021, 1:57 AM
    Sorry, one more dummy question: Is it possible in (especially in version 3.x.x) graphql endpoint to access response HTTP headers? Like in Spring you can create
    ResponseEntity<T>
    and set response status and HTTP headers directly inside Controller. Is it achievable in graphql endpoints as well?
    d
    • 2
    • 1
  • a

    Arun Kumar

    12/24/2021, 11:35 AM
    Hi team, trying to add the
    graphql-kotlin
    plugin to our gradle project. However when I try to run build the project, getting the following error. Have anyone seen this before?
    Execution failed for task ':runtime-service-web:graphqlIntrospectSchema'.
    > There was a failure while executing work items
       > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.IntrospectSchemaAction
          > Unable to run introspection query against the specified endpoint=<http://localhost:8080/graphql>
    .
    .
    Caused by: java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.MutablePropertyReference1Impl.<init>(java.lang.Class, java.lang.String, java.lang.String, int)'
            at io.ktor.utils.io.pool.DefaultPool$Companion$Top$1.<init>(DefaultPool.kt)
            at io.ktor.utils.io.pool.DefaultPool$Companion$Top$1.<clinit>(DefaultPool.kt)
            at io.ktor.utils.io.pool.DefaultPool.<clinit>(DefaultPool.kt:111)
            at io.ktor.utils.io.internal.ObjectPoolKt.<clinit>(ObjectPool.kt:12)
            at io.ktor.utils.io.ByteBufferChannel.<init>(ByteBufferChannel.kt:33)
            at io.ktor.utils.io.ByteChannelKt.ByteReadChannel(ByteChannel.kt:20)
            at io.ktor.utils.io.ByteChannelCtorKt.ByteReadChannel(ByteChannelCtor.kt:45)
            at io.ktor.client.engine.apache.ApacheRequestProducer.<init>(ApacheRequestProducer.kt:45)
            at io.ktor.client.engine.apache.ApacheEngine.execute(ApacheEngine.kt:36)
            at io.ktor.client.engine.HttpClientEngine$executeWithinCallContext$2.invokeSuspend(HttpClientEngine.kt:85)
            at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
            at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
            at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
            at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
    d
    • 2
    • 4
  • c

    Chris McQueen

    12/30/2021, 11:03 AM
    Morning all, I'm trying to use the
    graphqlGenerateSDL
    but it's failing due to using the `graphql-java-extended-scalars`'s
    BigDecimal
    - I can't see anywhere specify the scalars list from the docs like you can do in the
    client
    gradle task, does anyone know the approach for this?
    Execution failed for task ':graphqlGenerateSDL'.
    > There was a failure while executing work items
       > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction
          > Cannot convert java.math.BigDecimal? since it is not a valid GraphQL type or outside the supported packages "[com.example]"
    Thanks in advance
    d
    • 2
    • 2
  • b

    Brian Donovan

    01/02/2022, 2:20 AM
    hey all, I am currently using apollo graphql with KMM. I want to show the title, author, and background image. Display it on a card. I can log out the data but do not know how to display it on the screen. Can I get some help please. Also using compose.
    s
    • 2
    • 2
  • j

    Juan B

    01/06/2022, 7:12 AM
    Hi all, we are exploring using graphql-kotlin for a new set of services. We want to start with a monolith (single deployable artifact) but divide it internally into subdomains (like bounded contexts). Each subdomain (or bounded context) will have a graphql layer with the types exposed in the schema. We wanted to use type extensions to link the types across subdomains, but I believe it is not supported. Any thoughts on a way to implement something like type extensions? Down the road, we will break down the subdomains into microservices, and we will use federation, but we want to start with a componentized monolith.
    s
    • 2
    • 6
  • k

    Kanu

    01/06/2022, 11:41 AM
    Hi everyone, I'm trying to upgrade from kotlin 1.4 to 1.5 in the project with expedia v3.6.1 and get the following error:
    Caused by: com.expediagroup.graphql.exceptions.InvalidInputFieldTypeException: Argument cannot be an interface or a union, parameter #2 output of fun aaa.FuzzyDate.`write$Self`(aaa.FuzzyDate, kotlinx.serialization.encoding.CompositeEncoder, kotlinx.serialization.descriptors.SerialDescriptor): kotlin.Unit
    It sounds like red herring to me but maybe there is something I can fix? Or is it incompatibility between expedia 3 and kotlin 1.5? The class that is failing looks like this
    @Generated
    @Serializable
    data class FuzzyDate(val year: Int? = null, val month: Int? = null, val day: Int? = null, val current: Boolean? = false)
    • 1
    • 2
  • k

    Kanu

    01/06/2022, 12:42 PM
    Another issue: if I upgrade from expedia 3.6.1 to expedia 3.7.0 I get the following error
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    The bean 'graphQLContextFactory', defined in class path resource [com/expediagroup/graphql/spring/FederatedSchemaAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [aaa/GraphQLConfiguration.class] and overriding is disabled.
    
    Action:
    
    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
    • 1
    • 1
  • d

    Daniel Ryan

    01/06/2022, 6:06 PM
    Hi all, Does anyone have any advice regarding support for
    DataFetcherResult<List<DataFetcherResult<Entity>>>
    style return types as per this issue? https://github.com/ExpediaGroup/graphql-kotlin/issues/1337 I am happy to try and get a PR to add support for this; but before doing so, I wanted to make sure this requirement makes sense and get any advice on how to implement this feature?
    d
    • 2
    • 4
  • a

    Alexander Suraphel

    01/10/2022, 12:22 PM
    Do KGraphql or ExpediaGroup’s graphql-kotlin allow you to automatically generate graphql schema based your domains(db schema)?
    d
    • 2
    • 4
  • d

    Daniel Ryan

    01/10/2022, 4:23 PM
    Sorry to chase. If someone could review https://github.com/ExpediaGroup/graphql-kotlin/pull/1338 I would be very grateful as it is causing us some pain 🙂
    d
    • 2
    • 6
  • m

    Martin Brehovsky

    01/11/2022, 12:16 AM
    Hi all, a quick question regarding partial / complete failures. I know I can return both data and errors using
    DataFetcherResult
    , but I wonder if there is a way to completely fail the response (without any data being present), even though the fields might be nullable. I was looking around in the GraphQL Java Execution, but haven't found anything if there is a way to completely fail a query in the case of a specific error. However since this is the default policy in the case of non-nullable fields, I believe there must be a mechanism to do this. Any pointer? Thx!
    s
    • 2
    • 9
  • j

    jmfayard

    01/25/2022, 10:56 AM
    Hello, is there an equivalent or a way to implement the
    @constraint
    directive from ApolloGraphQL? https://www.apollographql.com/blog/backend/validation/graphql-validation-using-directives/
    type SignUpInput {
      email: String! @constraint(format: "email", maxLength: 255)
      password: String! @constraint(maxLength: 255)
    }
    d
    s
    • 3
    • 6
  • t

    Tobias

    02/04/2022, 1:52 PM
    I have some problems with nullability (not "undefinability"). I don't believe it's kotlin-graphql's fault, I just want to confirm the behaviour. If I understand this correct as per https://opensource.expediagroup.com/graphql-kotlin/docs/schema-generator/execution/optional-undefined-arguments/ I should not get NPE when doing
    fun optionalInput(value: String? = null): String? = value
    where
    value
    is
    null
    in the graphql variables, right? I should just get the
    value
    of
    null
    ?
    d
    • 2
    • 15
  • a

    Ashu Gairola

    02/07/2022, 7:31 PM
    Hello, I am trying to use gradle plugin to generate GraphQL schema file(s) from types defined in kotlin code. I keep getting this error:
    Execution failed for task ':graphqlGenerateSDL'.
    > There was a failure while executing work items
       > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction
          > Cannot calculate JVM erasure for type: ...
    Any suggestions on how to address this? The version is 4.1.1 for both
    graphql-kotlin-spring-server
    and
    graphql-kotlin-gradle-plugin
    d
    • 2
    • 11
  • t

    Tobias

    02/10/2022, 2:41 PM
    Is it a bug or a JVM/Jackson limitation that
    OptionalInput<List<Foo>>
    will become
    OptionalInput<List<LinkedHashMap>>
    runtime, or is it something I've done wrong?
    d
    • 2
    • 10
  • r

    rocketraman

    02/15/2022, 5:25 AM
    I'm thinking about having my query response types use functions to load data as needed. For example:
    data class SomeSuccessType(
      val foo: Foo,
      @property:GraphQLIgnore val bar: suspend () -> Bar?,
    ) {
      suspend fun bar() = bar.invoke()
    }
    With this approach my data model does not need to know anything about the various services and such being used to look up this data (like in the example given at https://opensource.expediagroup.com/graphql-kotlin/docs/server/data-loaders, the model class needs a reference to
    friendService
    and
    userService
    , which I think is messy to say the least). Instead, the loader logic here exists outside the data class/model and is simply injected via a function. However, when trying this approach, I am confronted with:
    Exception in thread "main" kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Cannot calculate JVM erasure for type: suspend () -> Bar?
      at kotlin.reflect.jvm.KTypesJvm.getJvmErasure(KTypesJvm.kt:36)
      at com.expediagroup.graphql.generator.internal.extensions.KTypeExtensionsKt.getKClass(kTypeExtensions.kt:38)
      at com.expediagroup.graphql.generator.internal.extensions.KTypeExtensionsKt.getQualifiedName(kTypeExtensions.kt:73)
      ...
    Any work-around for this? If not, what other techniques are people using to do data loading without all the messiness?
    d
    • 2
    • 4
  • r

    rocketraman

    02/16/2022, 5:06 PM
    Is there a way to get the current coroutine scope from the context? I want to start some
    async
    calls but can't create them in my own scope, because the async calls are lazy and will only resolve if the graphql server actually requests the fields that require the async data. Using
    GlobalScope
    works, but breaks structured concurrency.
    j
    • 2
    • 2
  • j

    Jared Rieger

    02/17/2022, 8:57 AM
    Hey all, I’m trying to test locally an extension on a type that is owned by another service. In my local playground I’m trying to use this query to be able to test the local extension
    query {
      _entities(representations: [{ __typename: Place, id: "some-id" }]) {
        ... on Place {
          people {
            name
          }
        }
      }
    }
    however this responds with a
    "Unable to resolve federated type, representation={__typename=Store, id=kl;fdjas}"
    error. Am I going about this the right way? Is there a way to test locally extensions on a type without somehow spinning up an Apollo server with the other services?
    d
    • 2
    • 3
  • j

    jmfayard

    02/17/2022, 9:25 AM
    I have an authentification mutation that currently returns a JWT token in the response body. I don't really like that because the browser has nowhere to securely store the token. I would like instead to set the
    Cookie
    header using my framework of choice (ktor). I understand how I can read Cookies and header before the GraphQL request with.
    GraphQLContextFactory
    but is it possible to set
    Cookie
    header after my GraphQL mutation succeeds? I would have expected this in
    environment: DataFetchingEnvironmen
    but no luck.
    j
    • 2
    • 1
Powered by Linen
Title
j

jmfayard

02/17/2022, 9:25 AM
I have an authentification mutation that currently returns a JWT token in the response body. I don't really like that because the browser has nowhere to securely store the token. I would like instead to set the
Cookie
header using my framework of choice (ktor). I understand how I can read Cookies and header before the GraphQL request with.
GraphQLContextFactory
but is it possible to set
Cookie
header after my GraphQL mutation succeeds? I would have expected this in
environment: DataFetchingEnvironmen
but no luck.
j

Joe

02/17/2022, 3:23 PM
We've done this in our dropwizard based server by having the mutation put a
NewCookie
instance into the
graphQLContext
map and setting it on the response. Something similar should be doable in a ktor based server. https://github.com/trib3/leakycauldron/blob/main/graphql/src/main/kotlin/com/trib3/graphql/resources/GraphQLResource.kt#L154-L158
👍 1
View count: 2