Generate client based on schema only from graphql-kotlin-maven-plugin -> generate-sdl #1556
-
Hi. We are baking a startup and came across usage of this lib. I wonder if it is possible to generate client just using only schema.graphql generated from 2 services with the usage of graphql-kotlin-maven-plugin -> generate-sdl ? Or how can I automatically generate query files based on sources that can be used for client generation ? While using generate-client goal it requires query files. I believe that query is already specified in schema.graphql My schema file
Like for Open Api I can use openapi-generator-maven-plugin that will generate all needed client code based on 1 open api json specification. With respect. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello 👋 There is a major difference between OpenAPI and GraphQL in that in the latter clients decide which fields they want to request (vs server dictating the full response in REST). GraphQL schema file defines the shape of your API and clients need to explicitly provide queries that define which data they want. Thats why you need both schema and query files in order to generate the client. There is no wildcard support in GraphQL and queries have to be explicit (see this issue), i.e. there is no For more details see https://graphql.org/learn/. |
Beta Was this translation helpful? Give feedback.
Hello 👋
There is a major difference between OpenAPI and GraphQL in that in the latter clients decide which fields they want to request (vs server dictating the full response in REST). GraphQL schema file defines the shape of your API and clients need to explicitly provide queries that define which data they want. Thats why you need both schema and query files in order to generate the client.
There is no wildcard support in GraphQL and queries have to be explicit (see this issue), i.e. there is no
SELECT * FROM schema
SQL equivalent. If your clients always request full schema then I am unsure whether you get much out of GraphQL and OpenAPI might be potentially better suited for your use ca…