Snippets for securing, transforming, and optimizing GraphQL APIs.

Overview


Logo

StepZen Snippets

Welcome! StepZen is a unique and declarative way to build & run any-sized Graph in minutes.

Table of Contents
  1. About The Project
  2. `@transforms`
  3. `@sequence`
  4. protection
  5. `@rest` calls and responses

About the project

This repo contains .graphql (and in some case, config.yaml files) for various "self-contained" example code for doing operations in StepZen.

Getting Started

Install the StepZen command line interface.

To run these examples,

  • git clone this repo
  • Change to the right working directory.
  • run stepzen start

@transforms

For more on what transforms is and how it operates within the custom @rest directive, see our documentation.

These are available in /transforms:

  • /filter shows how the response of a REST API can be filtered
  • /combineintostring shows how a new field in the return type can be created by concatenating some other fields (like address parts into one address)
  • /jsonobjectToJsonarray shows 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
  • /jsonobjectToJsonarray shows 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.

@sequence

View the StepZen documentation on the custom directive @sequence.

These are available in /sequence:

  • /arguments shows how query arguments get passed down a sequence
  • /forLoops shows how sequence acts as a nested for loop
  • /transformsInMaterializer shows how connecting two subgraphs can invoke transformations in between. For example, the city of a customer can be fed into a weather that takes lat,lon by calling some geocoding in the sequence
  • /useOfJSON shows 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.

protection

For more information on protecting your API, see our documentation.

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).

  • /makeAllPublic shows how you can easily make all queries public.
  • /makeSomePublic shows how you can make some public, and some private (which can still be accessed using your admin or service keys)

@rest calls and responses

Where possible, we use httpbin.org as our REST endpoint, since it allows us to mimic lots of REST capabilities.

  • /restWithParameters shows how GraphQL query arguments are automatically added to the REST call--there is nothing for you to do!
  • /restWithConfigYaml shows how REST query parameters can also be fetched from config.yaml--this allows you to keep your SDL code separate from your secrets.
  • /postbody shows how a POST body can be automatically filled with query arguments when the Content-Type:application/x-www-form-urlencoded. This is the easiest way to send postbodies down the REST API
  • /morecomplexpost shows how a POST body can be filled with query arguments using {{.Get \"name-of-query-argument\"}} when the Content-Type:application/x-www-form-urlencoded.
You might also like...

Code Playground is a online application for testing and showcasing user-created and collaborational HTML, CSS and JavaScript code snippets

Code Playground is a online application for testing and showcasing user-created and collaborational HTML, CSS and JavaScript code snippets

Code Playground About Code Playground is a online application for testing and showcasing user-created and collaborational HTML, CSS and JavaScript cod

Dec 17, 2022

microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex - A catalog of RegEx patterns View Demo · Report Bug · Request Feature Loved the tool? Please consider contributing ✍️ to help it improve!

Oct 25, 2022

A VS Code extension to practice and improve your typing speed right inside your code editor. Practice with simple words or code snippets.

A VS Code extension to practice and improve your typing speed right inside your code editor. Practice with simple words or code snippets.

Warm Up 🔥 👨‍💻 A VS Code extension to practice and improve your typing speed right inside your code editor. Practice with simple words or code snipp

Dec 12, 2022

A Kernel Package that adds a tab to Discord settings where you can add and arrange custom code snippets.

Code Snippets A Kernel package (specifically for Discord) that adds a tab in settings where you can add and manage code snippets. Requires: https://gi

Dec 14, 2022

An Obsidian plugin that provides commands for bulk enabling/disabling of plugins and CSS Snippets

An Obsidian plugin that provides commands for bulk enabling/disabling of plugins and CSS Snippets

An Obsidian plugin that provides commands for bulk enabling/disabling of plugins and CSS Snippets. Useful for debugging when you have many plugins or CSS snippets.

Dec 27, 2022

Collection of Rowy's templates for cloud functions cod snippets - including for derivative, action columns and extensions.

Collection of Rowy's templates for cloud functions cod snippets - including for derivative, action columns and extensions.

Rowy Templates Collection of Rowy's backend templates and code snippets for cloud functions - including for derivative, action columns and extensions.

Nov 16, 2022

Short JavaScript code snippets for all your development needs

Short JavaScript code snippets for all your development needs

30 seconds of code Short JavaScript code snippets for all your development needs Visit our website to view our snippet collection. Use the Search page

Dec 30, 2022

Short CSS code snippets for all your development needs

Short CSS code snippets for all your development needs

30 seconds of CSS Short CSS code snippets for all your development needs Visit our website to view our snippet collection. Use the Search page to find

Jan 3, 2023

official Alibaba Design system vue components snippets for visual studio code

official Alibaba Design system vue components snippets for visual studio code

Alibaba DLS Snippets for vscode Installation You can either install this extension by searching for Alibaba DLS Snippets in your vscode extensions sto

Sep 25, 2021
Comments
  • test: refactored to support array of tests

    test: refactored to support array of tests

    moved most of the deploy and run logic into gqltest.js and converted individual Test.js files to specify queries to test in an array and then invoke the deployAndRun function from gqltest.

    opened by bobbiejc 2
  • Tests for arguments, restWithParameters, and restWithConfigYaml

    Tests for arguments, restWithParameters, and restWithConfigYaml

    Adding query tests: sequence/arguments: added test-case that included… units for the weather; rest/restWithParameters: added test-case to omit 2nd argument rest/restWithConfigYaml: added first query test, likely only needs one. Also added a few comments to rest/restWithParameters/api.graphql

    opened by bobbiejc 0
  • test: adding query tests

    test: adding query tests

    Adding query tests: sequence/arguments: added test-case that included units for the weather; rest/restWithParameters: added test-case to omit 2nd argument rest/restWithConfigYaml: added first query test, likely only needs one.

    Also added a few comments to rest/restWithParameters/api.graphql

    opened by bobbiejc 0
  • add rest pagination snippet

    add rest pagination snippet

    Adds snippet showing pagination with @rest.

    Initially just PAGE_NUMBER, will add others once this is merged (as others will be almost carbon copies so want to get first approved).

    opened by ddebrunner 0
Owner
StepZen
Examples built by StepZen
StepZen
AWS SAM project that adds the snippets from serverlessland.com/snippets as saved queries in CloudWatch Logs Insights

cw-logs-insights-snippets Serverlessland.com/snippets hosts a growing number of community provided snippets. Many of these are useful CloudWatch Logs

Lars Jacobsson 12 Nov 8, 2022
Command-line toolkit for parsing, compiling, transpiling, optimizing, linking, dataizing, and running EOLANG programs

First, you install npm and Java SE. Then, you install eolang package: $ npm install eolang Then, you write a simple EO program in hello.eo file in th

objectionary 17 Nov 17, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
GraphQL-first boilerplate that scales with TypeScript + Node Express + Apollo GraphQL APIs.

graphql-typescript-boilerplate A boilerplate project for quickly building Graphql APIs and with typescript ?? Installation Install the dependencies: y

Youssef Hajjari 6 May 15, 2022
GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schemas (Federation, Stitching)

GraphQL Hive GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schem

Kamil Kisiela 184 Dec 21, 2022
SWC plugin for transforming import path.

swc-plugin-transform-import Inspired from babel-plugin-transform-imports Installation npm i -D swc-plugin-transform-import Uses with webpack-config //

Ankit Chouhan 35 Dec 24, 2022
NextJS with GraphQL using type-graphl and graphql-codegen adoptable dogs example code

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Jack Herrington 2 Mar 31, 2022
next-graphql-server is a library for building production-grade GraphQL servers using Next.js with API Routes

next-graphql-server next-graphql-server is an easy to use Next.js library for creating performant GraphQL endpoints on top of Next.js API Routes. Star

Jakub Neander 82 Nov 21, 2022