nfl / gold-starter

Wrapper for the gold project to provide endpoints for experimentation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gold-starter

Wrapper for the gold project to provide endpoints for experimentation.

Architecture

  • REST Controllers: The project employs Spring Boot and Spring Web to expose gold services
  • Services: gold-starter simply autowires all Spring components declared in gold and uses gold Facade: GraphQLSchemaService.executeQuery(...) and GraphQLInstanceService.executeQuery(...).
  • Persistence Layer: In memory hash maps are used to get the project up and running in no time.

Features

For the complete documentation of supported features, queries, mutations, etc please refer to gold documentation. This project simply exposes _gold_via REST. So, this document only mentions some default and tweaks it applies before calling gold.

Tweaks / defaults

To make experimentation simpler, gold-starter applies a few defaults before calling gold services:

  • Security: REST controllers automatically grant all gold permissions to all REST calls.
  • Namespaces: All schemas are in GOLD_STARTER_SCHEMA_NAMESPACE. All instances are in GOLD_STARTER_INSTANCE_NAMESPACE. No need to worry about namespaces or to specify them in any REST calls.
  • Nesting depth of queries is limited to 5 levels.

REST endpoint to manage schemas: /gold/definitions?query={query_contents}

Since this project simply delegates all processing to gold, it supports the same set of operations to view or modify a schema definition declared in gold documentation.
For a quick start:

  • POST the schema of a Pet to the schema definition endpoint, abbreviated example:
    POST http://localhost:8080/gold/definitions?query=mutation { upsertSchemaDefinition(schemaDef: { name: "Pet", ... } }
  • GET all schema definitions using this query to the same endpoint.

REST endpoint to manage instances: /gold/instances/{schemaName}?query={query_contents}

Assuming you have defined a Pet schema as suggested in the section above, you can populate the in memory repository with little effort:

http://localhost:8080/gold/instances/Pet?query=mutation {
  upsertSchemaInstance(schemaInstance: {
    id: "katie1234",
    name: "katie",
    weight: 75,
    type: Dog
  })
  {
    id,
    name,
    weight,
    type
  }
}

Just like gold, the schema instance interface supports mutation operations upsertSchemaInstance, removeInstance and removeAllInstances fully described there.

About

Wrapper for the gold project to provide endpoints for experimentation.

License:MIT License


Languages

Language:Java 100.0%