GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • GraphQL Java
  • Documentation
  • Book
  • Tutorial
  • Federation
  • Blog
  • Security
  • About
  • master
  • GitHub
  • Batching
  • Concerns
  • Contributions
  • Data fetching

This view

  • Original page
  • New address

GeezerVison is showing graphql-java.com — Getting started | GraphQL Java

Version: v25

graphql-java requires at least Java 11.

How to use the latest release with Gradle​

Make sure mavenCentral is among your repos:

  • Gradle
  • Gradle (Kotlin)
repositories {
mavenCentral()
}

dependencies {
implementation 'com.graphql-java:graphql-java:25.0'
}
repositories {
mavenCentral()
}

dependencies {
implementation("com.graphql-java:graphql-java:25.0")
}

How to use the latest release with Maven​

Dependency:

<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>25.0</version>
</dependency>

Hello World​

This is the famous "hello world" in graphql-java:

import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.schema.GraphQLSchema;
import graphql.schema.StaticDataFetcher;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;

import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring;

public class HelloWorld {

public static void main(String[] args) {
String schema = "type Query{hello: String}";

SchemaParser schemaParser = new SchemaParser();
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);

RuntimeWiring runtimeWiring = newRuntimeWiring()
.type("Query", builder -> builder.dataFetcher("hello", new StaticDataFetcher("world")))
.build();

SchemaGenerator schemaGenerator = new SchemaGenerator();
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);

GraphQL build = GraphQL.newGraphQL(graphQLSchema).build();
ExecutionResult executionResult = build.execute("{hello}");

System.out.println(executionResult.getData().toString());
// Prints: {hello=world}
}
}

Using the latest development build​

The latest development build is available on Maven Central.

Please look at the latest build for the latest version value.

How to use the latest build with Gradle​

Add the repository and dependency:

  • Gradle
  • Gradle (Kotlin)
repositories {
mavenCentral()
}

dependencies {
implementation 'com.graphql-java:graphql-java:INSERT_LATEST_VERSION_HERE'
}
repositories {
mavenCentral()
}

dependencies {
implementation("com.graphql-java:graphql-java:INSERT_LATEST_VERSION_HERE")
}

How to use the latest build with Maven​

Dependency:

<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>INSERT_LATEST_VERSION_HERE</version>
</dependency>
  • How to use the latest release with Gradle
  • How to use the latest release with Maven
  • Hello World
  • Using the latest development build
    • How to use the latest build with Gradle
    • How to use the latest build with Maven
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.