|
27 | 27 | - [Explore the docs](https://stepzen.com/docs)
|
28 | 28 | - [View Demo](https://stepzen.com/developers/videos/graph-of-graphs)
|
29 | 29 | - [Report Bug](https://github.com/stepzen-dev/snippets/issues)
|
30 |
| -- [Request Snippet](https://github.com/stepzen-dev/issues) |
| 30 | +- [Request Snippet](https://github.com/stepzen-dev/snippets/issues) |
31 | 31 | - [Join our Discord Server](https://discord.com/invite/9k2VdPn2FR)
|
32 | 32 | </p>
|
33 | 33 | </div>
|
34 | 34 |
|
35 |
| -<!-- TABLE OF CONTENTS --> |
36 |
| -<details> |
37 |
| - <summary>Table of Contents</summary> |
38 |
| - <ol> |
39 |
| - <li> |
40 |
| - <a href="#about-the-project">About The Project</a> |
41 |
| - </li> |
42 |
| - <li><a href="#transforms">`@transforms`</a></li> |
43 |
| - <li><a href="#sequence">`@sequence`</a></li> |
44 |
| - <li><a href="#protection">protection</a></li> |
45 |
| - <li><a href="#rest-calls-and-responses">`@rest` calls and responses</a></li> |
46 |
| - |
47 |
| - </ol> |
48 |
| -</details> |
49 |
| - |
50 | 35 | ## About the project
|
51 | 36 |
|
52 |
| -This repo contains `.graphql` (and in some case, `config.yaml` files) for various "self-contained" example code for doing operations in StepZen. |
| 37 | +This repo self-contained snippets that demonstrate use of custom directives and other techniques in |
| 38 | +IBM API Connect Essentials (StepZen). |
53 | 39 |
|
54 | 40 | ## Getting Started
|
55 | 41 |
|
56 |
| -[Install](https://stepzen.com/docs/quick-start/install-and-setup) the StepZen command line interface. |
57 |
| - |
58 |
| -To run these examples, |
59 |
| - |
60 |
| -- `git clone` this repo |
61 |
| -- Change to the right working directory. |
62 |
| -- run `stepzen start` |
63 |
| - |
64 |
| -## transforms |
65 |
| - |
66 |
| -For more on what `transforms` is and how it operates within the custom `@rest` directive, [see our documentation](https://stepzen.com/docs/custom-graphql-directives/directives#transforms). |
67 |
| - |
68 |
| -These are available in `/transforms`: |
69 |
| - |
70 |
| -- `/filter` shows how the response of a REST API can be filtered |
71 |
| -- `/combineintostring` shows how a new field in the return type can be created by concatenating some other fields (like address parts into one address) |
72 |
| -- `/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 |
73 |
| -- `/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. |
74 |
| - |
75 |
| -## @sequence |
76 |
| - |
77 |
| -View the StepZen [documentation](https://stepzen.com/docs/custom-graphql-directives/directives#-sequence) on the custom directive `@sequence`. |
78 |
| - |
79 |
| -These are available in `/sequence`: |
80 |
| - |
81 |
| -- `/arguments` shows how query arguments get passed down a sequence |
82 |
| -- `/forLoops` shows how sequence acts as a nested for loop |
83 |
| -- `/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 |
84 |
| -- `/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. |
85 |
| - |
86 |
| -## @dbquery |
87 |
| - |
88 |
| -View the documentation for the [`@dbquery` custom directive](https://www.ibm.com/docs/en/api-connect/ace/saas?topic=directives-directive-dbquery) in the documentation. |
89 |
| - |
90 |
| -Uses a database filled with mock data. |
91 |
| - |
92 |
| -- `/pagination` shows how to implement connection model pagination for a database. |
93 |
| - |
94 |
| -## protection |
| 42 | +Sign up for a free API Connect Essentials SaaS plan: https://www.ibm.com/account/reg/us-en/signup?formid=urx-52542 |
95 | 43 |
|
96 |
| -For more information on protecting your API, [see our documentation](https://stepzen.com/docs/access-control). |
| 44 | +Read: [understanding API Connect Essentials (StepZen)](https://www.ibm.com/docs/en/api-connect/ace/saas?topic=understanding-api-connect-essentials) |
97 | 45 |
|
98 |
| -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). |
| 46 | +[Install](https://www.ibm.com/docs/en/api-connect/ace/saas?topic=setting-up-your-environment#set-up-env__title__3) the StepZen command line interface. |
99 | 47 |
|
100 |
| -- `/makeAllPublic` shows how you can easily make all queries public. |
101 |
| -- `/makeSomePublic` shows how you can make some public, and some private (which can still be accessed using your `admin` or `service` keys) |
| 48 | +Documentation: https://www.ibm.com/docs/en/api-connect/ace/saas |
102 | 49 |
|
103 |
| -## @rest calls and responses |
| 50 | +## Snippets |
104 | 51 |
|
105 |
| -Where possible, we use [httpbingo.org](https://httpbingo.org) as our REST endpoint, since it allows us to mimic lots of REST capabilities. |
| 52 | +The snippets are generally broken up into functional areas, with each folder covering a specific topic: |
106 | 53 |
|
107 |
| -- `/restWithParameters` shows how GraphQL query arguments are automatically added to the REST call--there is nothing for you to do! |
108 |
| -- `/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. |
109 |
| -- `/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 |
110 |
| -- `/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`. |
| 54 | +### Custom Directives |
111 | 55 |
|
112 |
| -## union types |
| 56 | +- [@dbquery](dbquery/README.md) - Use `@dbquery` for connecting to databases, including pagination and filtering. |
| 57 | +- [@materializer](materializer) - Use of `@materializer` to extend types by linking disparate backends into a single unified view. |
| 58 | +- @rest - Connects to REST APIs |
| 59 | + - [rest](rest/README.md) - Use of `@rest` for connecting to REST endpoints, including pagination. |
| 60 | + - [transforms](transforms/README.md) - How to transform REST API responses to match GraphQL types with `@rest`. |
| 61 | +- [@sequence](sequence/README.md) - Use of `@sequence` to resolve a field from multiple field resolutions, such as multiple backend calls. |
| 62 | +- @sdl |
| 63 | + - [executable](executable) - How GraphQL _executable documents_ can be registered and used with a schema or endpoint. |
| 64 | +- @supplies |
| 65 | + - [routing](routing) |
113 | 66 |
|
114 |
| -Union types are valuable when you have a field that can return one of several types. |
| 67 | +### General topics |
115 | 68 |
|
116 |
| -- `/errorsAsData` shows how to implement the "errors as data" pattern. This is useful when you want to return a field that can return either a value or an error. |
| 69 | +- [pocs](pocs) - Techniques that can be used during development of proof of concepts with StepZen. |
| 70 | +- [protection](protection/README.md) - How to protect or expose GraphQL endpoints including field based access rules. |
| 71 | +- [reshape](reshape/README.md) - How to reshape GraphQL schema elements. |
| 72 | +- [unions](unions/README.md) - Uses of the GraphQL `union` type. |
117 | 73 |
|
118 | 74 | <!-- MARKDOWN LINKS & IMAGES -->
|
119 | 75 | <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
|
0 commit comments