r/graphlinkdotdev • u/graphlinkdev • 21d ago
We replaced our hand-written REST client with a schema-generated one: what improved, and what didn't change
Short version of the article: the backend behind optidialysis.com called Keycloak through Spring RestClient, with paths, headers and form bodies spread through one service. We moved it to a 95-line GraphQL schema with REST directives and generated the Java client from it (JDK HttpClient, no new HTTP library).
What improved: the whole contract is one reviewable file, contract drift is a compile error, there are no response classes to write by hand, and the client is easy to test against a fake server on the wire. The same schema can generate other languages, but we only ran Java.
What didn't change: our line count (359 to 362), because our server mode already generated the response types. The generator also can't do DELETE with a body, so one call is hand-built through the generated adapter. Full list of rough edges is in the article.
3
u/trodiix 21d ago
Why don't you just use the admin-client provided by keycloak instead of reinventing the wheel?