Skip to content

Instantly share code, notes, and snippets.

View schroedermatt's full-sized avatar

Matt Schroeder schroedermatt

View GitHub Profile
@schroedermatt
schroedermatt / animals-apiary.md
Last active June 12, 2017 19:57
Example API Blueprint for apiary.

FORMAT: 1A HOST: http://farmanimals.apiblueprint.org/

Animals API

Animals is a simple API allowing consumers to view information about the animals on a farm.

Animals Collection [/animals{?type}]

List All Animals [GET]

@schroedermatt
schroedermatt / zoo-schema
Last active June 23, 2017 20:28
schema for the zoo-graphql-example Spring Boot app
# Keeper
{
id: Long,
name: String,
animals: Animal[]
}
# Animal
{
id: Long,
@schroedermatt
schroedermatt / programmatic-schema.groovy
Last active December 28, 2018 16:32
Build GraphQL schema programmatically
GraphQLObjectType keeperType = newObject()
.name("keeper") // required
.description("A Zoo Keeper") // optional
.field(newFieldDefinition()
.name("id")
.description("Keeper ID")
.type(GraphQLLong)
.build())
.field(newFieldDefinition()
.name("name")
@schroedermatt
schroedermatt / idl-schema.graphqls
Last active June 23, 2017 20:44
Build schema using GraphQL IDL.
schema {
query: QueryType
}
type QueryType {
# (id: Long) allows for these fields to be filtered by id
animals(id: Long): [Animal]
keepers(id : Long) : [Keeper]
}
@schroedermatt
schroedermatt / graphql-project-structure
Last active June 28, 2017 17:26
General project structure for GraphQL in a Spring Boot app
graphql
|---- controller - exposes /v1/graphql POST endpoint
|---- executor - picks apart the request and executes the query against the schema
|---- schema - builds up the schema and provides it to the executor
|---- datafetcher - wraps calls to the database, external APIs, etc
@schroedermatt
schroedermatt / graphql-query-examples
Created June 27, 2017 20:53
A few examples of graphql queries
# retrieve all keepers names and the names of their animals
{
"query":"{ keepers { name animals { name } } }"
}
# retrieve keeper 1's name and their animals' name and birthdate
{
"query":"{ keepers(id: 1) { name animals { name birthdate } } }"
}
class PropertyResourceProvider implements SwaggerResourcesProvider {
// application.yml props get wired into this config
@Autowired
private SwaggerServicesConfig config
@Override
List get() {
config.services.collect { svc ->
new SwaggerResource(
name: svc.name,
@schroedermatt
schroedermatt / kafka-connect-build.gradle
Created June 21, 2018 17:16
Gradle build file for Kotlin Kafka Connector
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.jengelman.gradle.plugins:shadow:$shadow_version"
}
}
plugins {
id 'idea'
id 'com.palantir.git-version' version '0.5.2'
@schroedermatt
schroedermatt / kafka-connect-docker-compose.yml
Last active June 22, 2018 13:01
Docker compose snippet showing the volume mount for local development of a Connector.
connect:
image: confluentinc/cp-kafka-connect:latest
volumes:
- ./build/libs:/usr/share/java/kafka-connect-plugin-name
@schroedermatt
schroedermatt / TopicConfigurations.java
Last active July 24, 2018 20:22
Spring Kafka Config blog
@Configuration
@ConfigurationProperties(prefix = "kafka")
class TopicConfigurations {
List<TopicConfiguration> topics;
static class TopicConfiguration {
String name;
Integer numPartitions = 3;
Short replicationFactor = 1;