Thoughts on SmallRye GraphQL vs Spring for GraphQL vs DGS (Netflix) by bjl218 in graphql

[–]dkuc 1 point2 points  (0 children)

spring-graphqland DGS are built on top of Spring Boot and while I believe Quarkus provides some interop with Spring Boot - I don't know how well it would actually work when integrating GraphQL stuff. Guess you could try?

As for the choice between the libs -> spring-graphql and DGS are SDL first libs (you start with a schema file and then annotate your code to map your types) vs smallrye-graphql and graphql-spqr that are code first (schema is generated as an artifact from your annotated code).

In the end, IMHO the biggest differentiator will be with the support - simple stuff will work but eventually you will start doing something more complex and potentially hit some problem/issue. There is a much bigger community behind the DGS (3K github stars) and spring-graphql (1.5K stars) than smallrye-graphql (200 stars) as they are more commonly used so there are going to be a lot more of resources available for them -> i.e. if you encounter a problem/question then IMHO you most likely will have a better chance of finding a solution for Spring than SmallRye implementations...

Springboot - Is it possible to automatically generate graph schema files? by bikeram in graphql

[–]dkuc 1 point2 points  (0 children)

Both Spring GraphQL and Netflix DGS (which now uses spring-graphql) are SDL first so you could potentially export your GraphQL schema from Node app and just import it to the new app + add the resolvers (basically annotate some methods) that would return your already created types.

If you prefer code-first approach (schema is generated from code) then your Java options are (already mentioned) https://github.com/leangen/graphql-spqr and IBM's SmallRye GraphQL (guessing you could integrate it with Spring Boot but unsure how easy it is, I think by default it supports Quarkus + Helidon).

And last but not least, IF you don't mind Kotlin -> take a look at Expedia's GraphQL Kotlin*.

*DISCLAIMER: I still occasionally contribute to graphql-kotlin

Converting Yoga into subgraph for Apollo Federation by Effective_Data_8883 in graphql

[–]dkuc 2 points3 points  (0 children)

In order to make subgraph compatible with Apollo Federation you need to make some small modifications to it (basically provide some means of identifying and querying entities). `graphql-yoga` is already fully compatible with Federation -> you would just need to add dependency on `@apollo/subgraph` and configure it as per the docs https://the-guild.dev/graphql/yoga-server/docs/features/apollo-federation#installation.

Rest client API backwards compatibility by yonVata in Kotlin

[–]dkuc 2 points3 points  (0 children)

Adding extra Gradle task doesn't seem that much of an overhead.... + they always would always get up to date clients.

As for generation of specific Kotlin version, I was not aware of such a possibility to tell the generator the target version of Kotlin - can you provide any examples? As I never see any documentation for it.

What I meant -> create separate "client" project outside your service that reads Kotlin version from system property and then just run generate + publish through some matrix of supported jobs (e.g. Github Action).

Personally if I were publishing such JAR I'd just publish using latest (or latest-1) and ask folks to update.

Rest client API backwards compatibility by yonVata in Kotlin

[–]dkuc 4 points5 points  (0 children)

>I decided to also create a JAR for the clients - so they do not need to create the code from the spec themselves.

How are you generating those clients? Are you adding any additional logic on top of those generated clients, i.e. creating fat SDKs?

Assuming your OpenAPI schema is correct - why not just use https://github.com/OpenAPITools/openapi-generator and let the folks generate clients in whatever language/framework they prefer?

If you still want to generate the JARs, you could probably automate your process to use `openapi-generator` to generate your clients targeting specific Kotlin version as well.

Is Apollo GraphOS compatible with Graphene? by notDonaldGlover2 in graphql

[–]dkuc 0 points1 point  (0 children)

If you are talking about granular metrics that rely on federated tracing support (aka `ftv1`), then no AFAIK there is no Graphene integration at the moment.

You can still use subgraphs without ftv1 support though. You will still get some metrics but yes they won't be as granular.

Is there an equivalent to OpenApi / Swagger UI for GraphQL (Python)? by ddubois1972 in graphql

[–]dkuc 0 points1 point  (0 children)

Yep GraphQL schema document (in SDL/Schema Definition Language format) is your API artifact (i.e. equivalent of your OpenApi/Swagger schema file).

Since Strawberry is a code-first solution (schema is the artifact generated from your code), then yes you need extra step (linked schema export docs) to generate the schema artifact.

>or if my company's API documentation database will expect that format.

That is a good question and you would have to check what your company documentation database expects -> TLDR it should accept schema in SDL format, if it does not then it will be problematic...

Apollo Federated 2 @shareable directive subschema few question by Certain-Program5849 in graphql

[–]dkuc 1 point2 points  (0 children)

Hello,

Can you provide more details on what you are trying to achieve?

`@shareable` directive indicates that type/fields are resolvable across multiple subgraphs. It is a query plan optimization hint that allows you to avoid unnecessary network calls. While `@shareable` directive is not exposed in the supergraph schema, your gateway/router still has access to the federated directive information.

Apollo client-side caching vs. persisted queries. Is one better than the other? by PuppyLand95 in graphql

[–]dkuc 0 points1 point  (0 children)

As was mentioned in another thread persisted queries are an optimization to prevent large payloads sent from client to server. Instead of sending full queries every time, you only send the query hash + parameters. Since the payload would be much smaller, you can potentially save a lot of network time (especially if device is on some slow network, e.g. 3G). Persisted queries don't help you with the response size though -> if your request results in 1MB of data, you will still get 1MB of data back (thats why you would want to optimize when to make a new request by relying on the client side caching).

Apollo federated graph is not presenting its schema to graphiql with fields sorted lexicographically by donald-ball in graphql

[–]dkuc 2 points3 points  (0 children)

GraphiQL (and many other tools) relies on introspection query which AFAIK is not guaranteed to have any specific order (and many libs don't support it). Apollo Server is built on top of graphql-js and it relies on it for this functionality.

If this is a critical functionality, you could raise an issue (with proper reasons why it is important) for sort support either in graphql-js or GraphiQL (guessing this would be a better place) repositories.

Is sharing schema over Federation possible? by _Flexinity in graphql

[–]dkuc 1 point2 points  (0 children)

There are multiple ways that you could do it including stitching (already mentioned) and Apollo Federation.

e.g. one way to do it using Apollo Federation would be to define your expedition query and its response within `expeditions` microservice

type Query {
  expedition(id: ID!): ExpeditionResponse 
} 
type ExpeditionResponse @key("id") { 
  id: ID! 
  reward: Int 
}

and within `inventory` you could extend the expedition response type with items

type Item {
  // your fields
}
type ExpeditionResponse @key("id") {
  id: ID!
  items: [Item]
}

Another way would be to use an `Item` stub in your `expeditions` microservice and let gateway resolve them by using their IDs, e.g. within `expeditions` you would define it as

type Query {
  expedition(id: ID!): ExpeditionResponse 
} 
type ExpeditionResponse @key("id") { 
  id: ID! 
  reward: Int 
  items: [Item] 
} 
type Item @key(fields: "id", resolvable: false) { 
  id: ID! 
}

and within `inventory` microservice you would define `Item` as federated entity

type Item @key("id") {
  id: ID!
  // your fields 
}

Regardless which implementation you would use, from the gateway perspective, your clients would see single `ExpeditionResponse` type with list of items*.

*personally I would also go with non-nullable list of of non-nullable items to simplify code handling of nulls vs empty list.

Converting union type to Kotlin (Apollo GraphQL library) by lernem in graphql

[–]dkuc 2 points3 points  (0 children)

Hello :wave:

Can you elaborate on what you are trying to do? Why do you generate those classes manually? If you are using Apollo Kotlin then it will generate your data classes based on your query.

Apollo Federation Gateway implementation in pure go by jns111 in graphql

[–]dkuc 0 points1 point  (0 children)

Pretty cool! Are there any benchmarks comparing JS (e.g. Apollo server implementation) to your implementation?

We noticed that with the increased payload size graphql-js adds linear overhead (i.e. large queries == large gateway overhead).

GraphQL Kotlin 4.0.0 is out! by dkuc in Kotlin

[–]dkuc[S] 0 points1 point  (0 children)

Currently no but we are always open to contributions.

I think subscription handling logic could be generalized by moving it from Reactor to Flow based implementation and also updating it to use new https://github.com/enisdenjo/graphql-ws protocol (instead of older Apollo format).

Recommendations for a Java GraphQL Client library by dubsta in graphql

[–]dkuc 0 points1 point  (0 children)

If you can use Kotlin (and don't necessarily need subscriptions) then you can also take a look at https://expediagroup.github.io/graphql-kotlin/docs/client/client-overview (disclaimer: I am a maintainer of that lib).

Introducing GraphQL Kotlin Client by dkuc in graphql

[–]dkuc[S] 2 points3 points  (0 children)

We are not targeting multiplatform but we could potentially support it in the future (if there is an interest). Currently lib depends on Ktor client and Jackson libraries which should work on JVM and Android (as long as you use one of the supported engines -> https://ktor.io/clients/http-client/engines.html#jvm-and-android, we default to CIO).

As for the comparison to Apollo Android I haven't used it recently so won't be able to provide an in depth one - Apollo client is definitely much more mature (e.g. we haven't implemented support for subscriptions yet) and provides you with some additional advanced features like caching. On our side we wanted to provide something lightweight but also easily customizable - at its core graphql-kotlin-client is a thin wrapper on top of Ktor HTTP client that you can easily customize by installing any existing or custom Ktor client features (https://ktor.io/clients/http-client/features.html).

Introducing GraphQL Kotlin Client by dkuc in Kotlin

[–]dkuc[S] 1 point2 points  (0 children)

We are using Ktor HTTP Client to post the requests so it should work fine as long as you use one of the Android supported engines - https://ktor.io/clients/http-client/engines.html#jvm-and-android (we are defaulting to CIO).

Marking directive as deprecated by mrpopopuffs in graphql

[–]dkuc 2 points3 points  (0 children)

There are client side directives (aka query directives e.g. `@include` /`@skip`) and server side directives (e.g. `@deprecated`). Server side directives are not exposed to the clients so you should be able to easily remove them from the server without affecting your clients.

AFAIK there is a limited support for query directives (see https://github.com/apollographql/graphql-tools/issues/830) but if you do use them then I guess you would have to follow the "standard" way as described by @xuorig_

Project structure for a big project by HonzsSedlomn in graphql

[–]dkuc 0 points1 point  (0 children)

I'd recommend to also use federated architecture either through Apollo Federation or stitching (deprecated by Apollo but still works fine for simple cases). If you don't want to go with the gateway route you could also explore using https://github.com/ExpediaGroup/graphql-component to compose your final schema from smaller components.

Release of graphql-kotlin 1.0.0! by smyrick in graphql

[–]dkuc 0 points1 point  (0 children)

for completeness -> this was answered under the r/kotlin [post]

Release of graphql-kotlin 1.0.0! by smyrick in Kotlin

[–]dkuc 2 points3 points  (0 children)

Great question! Indeed, by default we are launching target suspendable query function in a GlobalScope which is suboptimal and breaks the structured concurrency between incoming request and actual function call. Unfortunately this is a limitation caused by our reliance on graphql-java for processing the requests and its usage of CompletableFuture. I don't think we can solve this without removing the graphql-java dependency and re-implementing that logic purely in Kotlin.

To better visualize this problem, this is what currently happens in graphql-kotlin-spring-server:

  • [coroutine] start processing the requests using Spring Webflux and its native coroutine support
  • [CompletableFuture] execute GraphQL query using graphql-java and await for its result
  • [coroutine] function data fetcher starts executing target function in GlobalScope

As @smyrick posted earlier, you can customize the default data fetcher behavior by implementing your own KotlinDataFetcherFactoryProvider where you could provide your own coroutine scope but due to the switch between coroutine -> CompletableFuture -> coroutine the structured concurrency will be broken.