Skip to content

StellateHQ/stellate-graphql-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stellate-graphql-java

This Java library integrates Stellate with your existing GraphQL Java and allows you to log metrics about your requests to Stellate.

It achieves this by exposing an Instrumentation that can be used with GraphQL Java.

Installation

This library is published to the Maven Central Repository:

  • groupId: co.stellate
  • artifactId: stellate

The library expects com.graphql-java:graphql-java to be installed in your project as well.

Gradle

Add the library to your list of dependecies in your build.gradle file:

dependencies {
  implementation 'co.stellate:stellate'
}

Maven

Add the dependency like so in your pom.xml file:

<project>
  <dependencies>
    <dependency>
      <groupId>co.stellate</groupId>
      <artifactId>stellate</artifactId>
      <version>0.0.1</version>
    </dependency>
  </dependencies>
</project>

Set up

When building your GraphQL object (from com.graphql-java), you can add the StellateInstrumentation exposed by this library like so:

import co.stellate.stellate.StellateInstrumentation;

// The name of your Stellate service
String serviceName = "my-stellate-service";

// A logging token for the above Stellate service
String token = "stl8log_xyz";

GraphQL myGraphQL = GraphQL.newGraphQL(schema)
    .instrumentation(new StellateInstrumentation(serviceName, token))
    .build();

Using with Spring

If you use Spring for GraphQL then you can get access to the GraphQL object to add the StellateInstrumentation like so:

import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import co.stellate.stellate.StellateInstrumentation;

@Configuration(proxyBeanMethods = false)
class GraphQlConfig {
    @Bean
    public GraphQlSourceBuilderCustomizer sourceBuilderCustomizer() {
        return (builder) -> builder.configureGraphQl(graphQlBuilder -> {
            graphQlBuilder.instrumentation(new StellateInstrumentation(
                serviceName,
                token
            ));
        });
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages