Skip to content

Instantly share code, notes, and snippets.

View bbakerman's full-sized avatar

Brad Baker bbakerman

View GitHub Profile
package graphql;
import graphql.language.FloatValue;
import graphql.language.IntValue;
import graphql.language.StringValue;
import graphql.schema.Coercing;
import graphql.schema.GraphQLScalarType;
import java.math.BigDecimal;
@bbakerman
bbakerman / gist:dad40b8197d00ed4b62c1377f92e99f2
Created March 1, 2017 08:41
Possible typed ExecutionStrategy approach
package graphql;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
@SuppressWarnings("Since15")
public class TestStuff {
class ExecutionResult {
@bbakerman
bbakerman / .groovy
Created May 23, 2017 12:41
Example test for null values
package graphql
import graphql.validation.ValidationError
import graphql.validation.ValidationErrorType
import spock.lang.Specification
/*
* Taken from http://facebook.github.io/graphql/#sec-Input-Objects
*
*
package example.http;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.StarWarsData;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
DataFetcher userDataFetcher = new DataFetcher() {
@Override
public Object get(DataFetchingEnvironment environment) {
CompletableFuture<User> userPromise = CompletableFuture.supplyAsync(
() -> {
return fetchUserFromDatabase(environment.getArgument("userId"));
});
return userPromise;
}
};
// a batch loader function that will be called with N or more keys for batch loading
BatchLoader<String, Object> characterBatchLoader = new BatchLoader<String, Object>() {
@Override
public CompletionStage<List<Object>> load(List<String> keys) {
//
// we use supplyAsync() of values here for maximum parellisation
//
return CompletableFuture.supplyAsync(() -> getCharacterDataViaBatchHTTPApi(keys));
}
};
@bbakerman
bbakerman / com.atlassian.auiplugin:aui-experimental-soy-templates.js
Created December 15, 2017 00:49
com.atlassian.auiplugin:aui-experimental-soy-templates
/* module-key = 'com.atlassian.auiplugin:aui-experimental-soy-templates', location = 'src/soy/aui.soy' */
// This file was automatically generated from aui.soy.
// Please don't edit this file by hand.
/**
* @fileoverview Templates in namespace aui.
*/
if (typeof aui == 'undefined') { var aui = {}; }
Index: src/main/java/graphql/execution/instrumentation/dataloader/DataLoaderDispatcherInstrumentation.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/graphql/execution/instrumentation/dataloader/DataLoaderDispatcherInstrumentation.java (date 1521428082000)
+++ src/main/java/graphql/execution/instrumentation/dataloader/DataLoaderDispatcherInstrumentation.java (revision )
@@ -23,9 +23,12 @@
import java.util.ArrayDeque;
import java.util.Collections;
// And example bit of code
// marked by
// ::FigureA
for (java.util.Enumeration entries = zf.entries(); entries.hasMoreElements();) {
// Get the entry name and write it to the output file
String newLine = System.getProperty("line.separator");
String zipEntryName =
((java.util.zip.ZipEntry)entries.nextElement()).getName() +
newLine;
writer.write(zipEntryName, 0, zipEntryName.length());
package graphql.execution.instrumentation.dataloader
import graphql.ExecutionInput
import graphql.TestUtil
import graphql.schema.DataFetcher
import org.dataloader.BatchLoader
import org.dataloader.DataLoader
import org.dataloader.DataLoaderOptions
import org.dataloader.DataLoaderRegistry
import spock.lang.Specification