Demo repository to find to showcase how to use Netflix's dgs to make API calls to a graphql server.
- Generate POJO from graphQL schema (obtained
from https://lucasconstantino.github.io/graphiql-online/, stored
in
src/main/resources
) by running./gradlew generateJava
- Run individual test cases in
SpringDgsClientDemoApplicationTests
for different scenarios
dgs
client code generator is simply a wrapper. You can manually provide GraphQL query string instead of generating query/mutation from generated POJO if certain functionalities (alias, nested arguments) are not supporteddgs
providesgradle
plugin to auto-generate POJO from.graphqls
file. It's not available formaven
- In general, there's an abundance of libraries that help set up a GraphQL server but there aren't many that supports calling one (could be wrong).
- It seems that
dgs
client code generation has a limitation where it seemingly could not query multiple fields in root Query. For example, this could not be done via generated client code:query { continents(filter: {code:{eq:"AF" } }) { code name }, countries{code name} }
dgs
client code generator also does not seem to support alias. There is an open PR here. This can still be done with manual query but requires custom object/model that matches the alias