项目作者: Ramkishorevit

项目描述 :
A Retrofit 2 Converter.Factory for GraphQL.
高级语言: Java
项目地址: git://github.com/Ramkishorevit/GraphQL-Retrofit-Converter.git


GraphQL-Retrofit-Converter

==============================

A Retrofit 2 Converter.Factory for GraphQL.

Usage

Add a converter factory when building your Retrofit instance using either the
stringBased or bytesBased factory methods:

  1. val retrofit = Retrofit.Builder()
  2. .baseUrl("https://example.com/")
  3. .addConverterFactory(GraphQLConverter.create(this))
  4. .build()

Now when you build your API interface use it like this,

  1. @POST("/")
  2. @GraphQuery("filename")
  3. fun getResponse(@Body query: QueryContainerBuilder): Call<T>

Note filename here refers to filename.graphql file which contains the actual GraphQL query
that should be placed in assets->graphql-> <>.

QueryContainerBuilder is an in-built model class that allows to set variables
(if any) in the graphql query.Hence it might also be null

The variables in the query can be set like this,

  1. val queryContainer = QueryContainerBuilder()
  2. queryContainer.putVariable("id",1)

Download

Grab via Maven:

  1. <dependency>
  2. <groupId>com.ramkishorevs.graphqlretrofitconverter</groupId>
  3. <artifactId>graphqlconverter</artifactId>
  4. <version>1.0.0</version>
  5. <type>pom</type>
  6. </dependency>

or via Gradle

  1. compile 'com.ramkishorevs.graphqlretrofitconverter:graphqlconverter:1.0.0'

License

  1. Copyright 2018 Ramkishore V S
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.