GRAPHQL's GRAPHQL Java tools overview

Source: Internet
Author: User

GRAPHQL Java Tools is a software package that can build a corresponding Java Pojo type object from the GRAPHQL schema definition *.graphqls file.

The latest version of GRAPHQL Java Tools is the 2017.11 release of 4.3.0.

1. The project name GRAPHQL Java Tools is Graphql-java-servlet and relies on the following software modules: com.graphql-java:graphql-java:6.0 com.fasterxml.jackson.core:jackson-*:2.8.8 2. Working model of GRAPHQL Java tools

*.graphqls file <-> Pojo type Object <-> resolvers object <-> Data Repository Object

3. GRAPHQL Java Tools provides a variety of resolvers interfaces for populating Pojo type objects with data 1) three root resolvers (both inherited from Graphqlresolver)
Graphqlqueryresolver Graphqlmutationresolver Graphqlsubscriptionresolver

2 In addition, any Pojo type object referencing other Pojo types inherits the definition of the Resolvers class from Graphqlresolver.

All Resolvers objects, when Schemaparser generates Graphqlschema, are supplied to the. resolvers (...) in the form of a parameter. Method.

4. GRAPHQL Java Tools is able to automatically correlate to resolvers methods for fields in Pojo objects, and development work as follows:

1 A new fields is given in the *.graphqls file (that is, the fields is present in the Pojo type Object), as detailed in the GRAPHQL specification.

2 in the Resolvers class to give the corresponding fields access method, the method named as follows (optional): <fieldname> (Datarepositoryclassinstance, *fieldargs [, Datafetchingenvironment]) is<fieldname> (datarepositoryclassinstance, *fieldargs [, DataFetchingEnvironment]) Get<fieldname> (Datarepositoryclassinstance, *fieldargs [, datafetchingenvironment]) getField<Fieldname > (Datarepositoryclassinstance, *fieldargs [, Datafetchingenvironment])

Of these, datafetchingenvironment are optional.

3 in the Datarepository class to give the corresponding data access method, the method named as follows (optional): <fieldname> (*fieldargs [, datafetchingenvironment]) is< Fieldname> (*fieldargs [, Datafetchingenvironment]) get<fieldname> (*fieldargs [, DataFetchingEnvironment]) Getfield<fieldname> (*fieldargs [, Datafetchingenvironment])

Of these, datafetchingenvironment are optional.

5. Refer to GRAPHQL Java Tools in the MAVEN project, referenced in Pom.xml as follows:

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId> graphql-java-tools</artifactid>
    <version>4.3.0</version>
</dependency>

Reference Links:

Https://github.com/graphql-java/graphql-java-tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.