Dariusz Kuc
11/27/2019, 2:39 PMgraphql-kotlin
library. Post today highlights how graphql-kotlin-federation
can be used to generate Federated GraphQL schemas directly from your source code - https://medium.com/expedia-group-tech/apollo-federation-in-a-graphql-kotlin-server-115cea51607a
Stay tuned for the next post in the series that will highlight spring server module!Dariusz Kuc
12/03/2019, 2:30 PMgraphql-kotlin
library. Post today highlights how easy it is to create reactive GraphQL web applications in Kotlin using graphql-kotlin-spring-server
-> https://medium.com/expedia-group-tech/creating-a-reactive-graphql-server-with-spring-boot-and-kotlin-54aca7316470
We will be presenting graphql-kotlin
this Thursday @kotlinconf (4:15 GMT+1). You can sign up for the streams at https://kotlinconf.com/Andy Marwood
02/12/2020, 4:28 PM@GraphQLVariables
working with a different name to the argument you are assigning it to? For example (sorry if the syntax isn’t quite perfect):
query($dateFormat: String) { user(format: $dateFormat) { } }
Matthew Browning
03/19/2020, 3:52 PMAndrew
03/29/2020, 4:50 PMPaul O'Donoghue
04/01/2020, 3:44 PMGerard Klijs
04/02/2020, 9:58 AMShane Myrick
04/14/2020, 4:32 PMJoe
04/17/2020, 10:59 PMallUsers()
query to the nested fields documentation page schema, and having a client request allUsers() {photos(1)}
to get the first photo for each user)? Exposing the nested children as a function is really cool from a simplicity of writing code perspective, but ends up executing one fetch per Parent (exposing it as a suspend function at least runs them concurrently). Is looking at the DataFetchingEnvironment
and then performing different fetch logic based on the selectionSet the best way to try to optimize the fetches? Or is there another/better way of thinking about this use case?tim
06/09/2020, 6:08 PMfun testQuery(id: Id): DataFetcherResult<String> {
return DataFetcherResult
.newResult<String>()
.error(Failure.App.Unknown)
.build()
}
But bc String is non nullable, I get a 'NullValueInNonNullableField' error when this result is returned to my graphql client. If I put .data(null)
into the builder pattern, then I get an error about String being non nullable and then I get a slightly different error.
I assume that if an error occurs, returning null is correct, but I'd prefer to not have nullable return values if I can avoid it?Joe
06/11/2020, 11:18 PMDataFetchingEnvironment.selectionSet
? Just ran into https://github.com/graphql-java/graphql-java/issues/1545 and can workaround some cases of it relatively easily, but others less so. We look at the qualifiedName of the leaf fields of the selectionSet to dynamically decide how to build our underlying query. When that leaf field is aliased, we can use SelectedField.name
to go back to the schema name and build the right query to run, but if a parent field is aliased, there doesn't seem to be a way to access the schema-qualified name, only the aliased one?James Fagan
06/12/2020, 9:52 AMJoe
09/11/2020, 3:37 PMFunctionDataFetcher::runSuspendingFunction
using GlobalScope
instead of an existing scope?
Right now, I can put a scope in the context, and in my Query object do something like:
fun cancellable(env: DataFetchingEnvironment): CompletableFuture<String> {
return env.getContext<CoroutineScope>().future {
delay(100)
"result"
}
}
And then cancel a running query via the context scope's .cancel()
I'd like to be able to do something like:
suspend fun cancellable(): String {
delay(100)
return "result"
}
But when I do so, the coroutineContext is not inherited (eg, MDCContext() doesn't place MDC values for logging) and cancelling the parent scope doesn't cancel the created coroutine. I can make it work with a FunctionDataFetcher
subclass that looks for a scope-implementing context and uses that (falling back to GlobalScope if there isn't one). Does that seem like the right approach? Would a PR doing that in FunctionDataFetcher
be welcome?Hector Gonzalez
10/01/2020, 2:14 PMschoolId
. The catch being that the Student schema and School schema are in separate services. Not sure what I'm missing. I am unable to "join" both types using the resolver. Can you kindly help me out? Here´s the code:
*const* VCDB_URI = '<http://localhost:4001/graphql>'
*const* PCDB_URI = '<http://localhost:4002/graphql>'
//Define schema extensions
`*const* typeDefs = ``
extend type Student {
schoolId: School
}
``;`
*const* resolvers = {
Student: {
schoolId(parent, args, context, info) {
return delegateToSchema({
schema: typeDefs,
operation: 'query',
fieldName: 'getBySchoolId',
args: {
schoolId: parent.id,
},
context,
info,
});
}
}
}
//Define the gateway
*const* gateway = new ApolloGateway({
serviceList: [
{ name: 'vcdb', url: VCDB_URI },
{ name: 'pcdb', url: PCDB_URI },
],
extensions: typeDefs,
resolvers: resolvers,
debug: true
});
//Define the server
*const* server = new ApolloServer(
{ gateway,
subscriptions: false,
});
//Start up the server
server.listen({
port: 4000,
*}).then(({ url }) =>* {
`*console.log(*:rocket: *Server ready at ${url}
);*`
});
Felix Honer
01/08/2021, 8:27 PMSaharath Kleips
02/03/2021, 9:55 PMspeed_star
02/10/2021, 2:42 AMdave08
02/18/2021, 10:26 AMspeed_star
02/25/2021, 1:56 PMjoshr
03/06/2021, 4:26 AMandylamax
04/25/2021, 10:22 AMRupesh
05/27/2021, 2:45 AMSlackbot
09/13/2021, 3:46 PMArnab
11/26/2021, 11:15 AMAlexander Suraphel
01/16/2022, 2:33 PMJustin
03/11/2022, 5:54 PMmyschema.graphql
schema file as input and output a collection of kotlin files containing kotlin data classes for that schema?
For example, this GraphQL schema:
myschema.graphql
type User {
"""
The unique identifier for the user
"""
id: String!
"""
User first and last name
"""
name: String!
"""
Gender identity of user
"""
gender: Gender
}
enum Gender {
MALE
FEMALE
OTHER
UNKNOWN
}
...would generate:
User.kt
data class User(
val id: String,
val name: String,
val gender: Gender
)
Gender.kt
enum class Gender {
MALE, FEMALE, OTHER, UNKNOWN;
}
tim
04/12/2022, 4:02 PMMelvin Biamont
10/10/2023, 3:24 PMgraphql-kotlin
obviously, but:
• when I started, graphql-kotlin
wasn't existing (or at a very early stage if I remember well)
• I wanted something lighter, easy to setup and play with
For personal reasons, I wasn't able to work on this project, but I finally finished it!
🚀 Allow me to introduce ArianeGraphQL (a clear reference to Apollo 😉).
I wrote a Medium post here: https://melvinbiamont.medium.com/lightweight-kotlin-graphql-server-5a26b6cab6d6
Feel free to share your thoughts on Medium or discuss it directly here in 🧵.martmists
11/22/2024, 11:29 AMgraphqls
schema file, and supports queries, mutations and subscriptions (using the graphql-transport-ws
protocol).
If you want to write graphql queries while sticking closely to the syntax with proper checking, you can now just write
val me = myGraphQLClient.query {
me {
name
id
fragment on AdminUser { // for lack of `... on AdminUser`
capabilities
}
}
}
println(me.name)
if (me is AdminUser) {
println(me.capabilities)
}
and it'll return fully typed data 🙂
As for the server, the DSL mostly inspired by KGraphQL with some small improvements where I felt it was necessary, as well as being fully suspending, supporting interface types, arguments and including error paths.
Any feedback would be much appreciated!Matthew
02/01/2025, 4:17 PM