This repo contains .graphql (and in some case, config.yaml files) for various "self-contained" example code for doing simple operations in StepZen
To run these examples,
git clonethis repo- Change to the right working directory.
- run
stepzen start
These are available in /transforms:
/filtershows how the response of a REST API can be filtered/combineintostringshows how a new field in the return type can be created by concatenating some other fields (like address parts into one address)/jsonobjectToJsonarrayshows how an array of data (say coords) can be converted into an object,{"lat":, "lon",..}so that it can be fed into some other system that requires data to be expressed that way/jsonobjectToJsonarrayshows how an object (typically where each key is an id of a record) can be converted into an array (e.g.,{"1":{"name": "john"}, "2": "jane"}can be converted to[{"id":"1", "name": "john"}, {"id":"2", name: "jane"}]), so that it can then behave well for GraphQL processing.
These are available in /sequence:
/argumentsshows how query arguments get passed down a sequence/forLoopsshows how sequence acts as a nested for loop/transformsInMaterializershows how connecting two subgraphs can invoke transformations in between. For example, thecityof a customer can be fed into aweatherthat takeslat,lonby calling some geocoding in the sequence/useOfJSONshows how, in long sequences, a new type does not have to created for every step--treat everything as JSON up to the last step, and your type system stays clean.
In /protection, you will find several subdirectories. Each contains a .graphql file, and index.graphql file and a config.yaml settings (which enables you to get extremely granular (or coarse) with protecting who can call what query/mutation).
/makeAllPublicshows how you can easily make all queries public./makeSomePublicshows how you can make some public, and some private (which can still be accessed using youradminorservicekeys)
Where possible, we use httpbin.org as our REST endpoint, since it allows us to mimic lots of REST capabilities.
In the repos below, we have given the code that you will likely not handwrite, you will just use stepzen import curl but it is worthwhile to look at the generated code, which is what we will use to show different ways in which REST calls can be made, and the responses be modified.
/restWithParametersshows how GraphQL query arguments are automatically added to the REST call--there is nothing for you to do!/restWithConfigYamlshows how REST query parameters can also be fetched fromconfig.yaml--this allows you to keep your SDL code separate from your secrets./postbodyshows how a POST body can be automatically filled with query arguments when theContent-Type:application/x-www-form-urlencoded. This is the easiest way to send postbodies down the REST API/morecomplexpostshows how a POST body can be filled with query arguments using{{.Get \"name-of-query-argument\"}}when theContent-Type:application/x-www-form-urlencoded.