Test GraphQL Java

A library to convert a GraphQL file to request payload string

Лицензия

Лицензия

Категории

Категории

Java Языки программирования
Группа

Группа

com.vimalselvam
Идентификатор

Идентификатор

test-graphql-java
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Test GraphQL Java
A library to convert a GraphQL file to request payload string
Ссылка на сайт

Ссылка на сайт

http://www.vimalselvam.com
Система контроля версий

Система контроля версий

https://github.com/vimalrajselvam/test-graphql-java

Скачать test-graphql-java

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.vimalselvam/test-graphql-java/ -->
<dependency>
    <groupId>com.vimalselvam</groupId>
    <artifactId>test-graphql-java</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.vimalselvam/test-graphql-java/
implementation 'com.vimalselvam:test-graphql-java:1.0.0'
// https://jarcasting.com/artifacts/com.vimalselvam/test-graphql-java/
implementation ("com.vimalselvam:test-graphql-java:1.0.0")
'com.vimalselvam:test-graphql-java:jar:1.0.0'
<dependency org="com.vimalselvam" name="test-graphql-java" rev="1.0.0">
  <artifact name="test-graphql-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.vimalselvam', module='test-graphql-java', version='1.0.0')
)
libraryDependencies += "com.vimalselvam" % "test-graphql-java" % "1.0.0"
[com.vimalselvam/test-graphql-java "1.0.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.fasterxml.jackson.core : jackson-databind jar 2.9.9

test (2)

Идентификатор библиотеки Тип Версия
com.squareup.okhttp3 : okhttp jar 4.0.0-alpha02
org.testng : testng jar 6.8

Модули Проекта

Данный проект не имеет модулей.

Build Status Maven Central

Test GraphQL Java

This library let's you to convert the GraphQL file to a simple string which can be used as a request payload using any HTTP client library.

I've written this library for the simple GraphQL API Testing. There is a graphql-java library which let's you to implement GraphQL server in Java. My main goal is not to introduce Spring Boot just for the sake of testing the GraphQL API. I wanted to keep it simple!

To use this library, you can download from Maven:

<dependency>
    <groupId>com.vimalselvam</groupId>
    <artifactId>test-graphql-java</artifactId>
    <version>1.0.0</version>
</dependency>

I don't use Gradle, but it should be simple to add this as a gradle dependency.

Getting Started

There are two ways to load the GraphQL file.

  • using InputStream:

    InputStream iStream = getClass().getResourceAsStream("/graphql/pokemon.graphql");

    Here the pokemon.graphql file in under src/test/resources/graphql/pokemon.graphql.

  • using File:

    File file = new File("src/test/resources/graphql/pokemon.graphql");

Once you read the file, just pass it to GraphqlTemplate class to parse as follows:

String graphqlPayload = GraphqlTemplate.parseGraphql(file, variables);

Here the variables is the com.fasterxml.jackson.databind.node.ObjectNode. If no variables, you just pass null.

To build the variables, you can do:

ObjectNode variables = new ObjectMapper().createObjectNode();
variables.put("name", "Pikachu");

Then you can use any HTTP Client and pass the graphqlPayload string as a body.

A sample test can be found here

Версии библиотеки

Версия
1.0.0