Coder Social home page Coder Social logo

graphql-java-type-generator's Introduction

graphql-java-type-generator

THIS PROJECT IS NOT LONGER MAINTAINED AND IN READ ONLY MODE

About

This library will autogenerate GraphQL types for usage in com.graphql-java:graphql-java

The generation of types can be controlled using different strategies.

A default strategy implementation is provided, one which reads java .classes through reflection.

The default strategy is augmentable to customize any aspect at all.

In fact, there is a customizable strategy for everything from the name of a type, to which DataFetcher a field uses, down to which input arguments are available.

Usage

Since everything about type generation is configurable, types are generated based upon a BuildContext that specifies the various strategies, parameters, and type repositories.

A DefaultBuildContext is provided, or another one can be made.

The best entry point to this library is BuildContext's .getOutputType(obj), .getInputType(obj), or .getInterfaceType(obj).

Direct access is given if, for example, only fields are needed.

FAQ

  • Recursive object creation? Yes.
  • Java Generics? Yes, as long as type erasure has not happened.
  • Enums? Yup
  • Unions? Not yet... java doesn't really have those natively.
  • Lists? Yes, and lists of lists
  • Scalars? We additionally handle BigInteger and BigDecimal, byte, short, and char

Let us know what else you need.

graphql-java-type-generator's People

Contributors

0xr avatar andimarek avatar blesswinsamuel avatar danielkwinsor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-java-type-generator's Issues

Upgrade to graphql-java 3.0.0

Would be nice, I tried upgrading manually, but a unit test failed. I'm not familiar enough with the internals to figure out what is going on.

can't generate by Map.class

I have got a error when runing like this
BuildContext buildContext= DefaultBuildContext.reflectionContext; GraphQLOutputType a=buildContext.getOutputType(Map.class);

and the error result is

7:55.723 [main] WARN graphql.java.generator.type.TypeGenerator - Failed to generate type named sun_reflect_generics_reflectiveObjects_TypeVariableImpl with kind INPUT_OBJECT 14:47:55.728 [main] DEBUG graphql.java.generator.type.TypeGenerator - Failed to generate type, exception is graphql.AssertException: wrappedType can't be null at graphql.Assert.assertNotNull(Assert.java:10) at graphql.schema.GraphQLList.<init>(GraphQLList.java:13)

Unions

Best way to do it is via an interface

class Rabbit implements AnimalUnion {...}
class Dog implements AnimalUnion {...}

this will generate
union Animal = Rabbit | Dog

My 2c

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.