Examples

StuccoJS Examples

This example shows a simple GraphQL schema with one string field resolver:

schema.graphql
type Query{
    hello: String
}
schema{
    query: Query
}
stucco.json
{
    "resolvers":{
        "Query.hello":{
            "resolve":{
                "name": "lib/hello"
            }
        }
    }
}
hello.js
export function handler(input){
    return "Hello world"
}

When the following query is executed:

GraphQL query
{
    hello
}

It should yield this response:

Response
{
    "hello": "Hello world"
}

Last updated