Wrapper for the gold project to provide endpoints for experimentation.
- 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.
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.
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.
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.
Assuming you have defined a Pet schema as suggested in the section above, you can populate the in memory repository with little effort:
- POST some pets (katie_dog.txt,
tweety_bird.txt, larry_lizard.txt)
to this instance management endpoint.
Example POST request:
http://localhost:8080/gold/instances/Pet?query=mutation {
upsertSchemaInstance(schemaInstance: {
id: "katie1234",
name: "katie",
weight: 75,
type: Dog
})
{
id,
name,
weight,
type
}
}
- GET all pets at the same endpoint using a query like in instance_list.txt.
Just like gold, the schema instance interface supports mutation operations upsertSchemaInstance, removeInstance and removeAllInstances fully described there.