Skip to content

Explore Netflix's DGS library usage as a client trying to consume GraphQL API

Notifications You must be signed in to change notification settings

aurelius0523/spring-dgs-client-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-dgs-client-demo

Demo repository to find to showcase how to use Netflix's dgs to make API calls to a graphql server.

Getting started

  1. Generate POJO from graphQL schema (obtained from https://lucasconstantino.github.io/graphiql-online/, stored in src/main/resources) by running ./gradlew generateJava
  2. Run individual test cases in SpringDgsClientDemoApplicationTests for different scenarios

Learnings

  1. 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 supported
  2. dgs provides gradle plugin to auto-generate POJO from .graphqls file. It's not available for maven
  3. 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).
  4. 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}
    }
  5. 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

About

Explore Netflix's DGS library usage as a client trying to consume GraphQL API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages