Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reshape/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Reshaping is combined with access control of GraphQL fields so that

In all of the reshaping examples fields that are part of the reshaped api are accessible with no authorization.

> **Note**
> [!NOTE]
> Any reshaped GraphQL schema can also be expanded with any StepZen GraphQL functionality, such as adding fields with `@materializer` or adding `@sequence` fields that invoked fields from reshaped and or original schema.

## Techniques
Expand Down
9 changes: 4 additions & 5 deletions reshape/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is achieved with a combination of:
- Use of `@materializer` for the [new root operation type fields](exposed.graphql).
- [Field based access control](config.yaml) to only expose the new fields.

> **Note**
> [!NOTE]
> Even though this schema uses `@graphql` the techniques are independent of the data coming from a backend GraphQL endpoint, the reshaping is just against fields in the schema regardless of their source.

## Rename
Expand Down Expand Up @@ -59,7 +59,7 @@ the `city` field is a leaf `String`, rather than being buried in a `Location` ob

[`Query.humanName`](exposed.graphql#L32-L35) uses the selection `human { name }` which selects just a `Human`'s name. It is effectively executing `query ($id:ID!) {human(id:$id) { name }}` when `humanName` is selected in an operation.

[`Query.droidFriends`](exposed.graphql#L37-L40) uses the selection `droid { friends }` where `friends` type is a composite type, `[Character]`. Even though the selected single field `friends` is a composite type, it has no selection in its `@materializer`. Instead, when an operation is executed that selects `droidFriends`, the selection against that field is applied to the selection of `friends`. For example the execution of this operation
[`Query.droidFriends`](exposed.graphql#L37-L40) uses the selection `droid { friends }` where `friends` type is a composite type, `[Character]`. Even though the selected single field `friends` is a composite type, it has no selection in its `@materializer`. Instead, when an operation is executed that selects `droidFriends`, the selection against that field is applied to the selection of `friends`. For example the execution of this operation

```graphql
query DroidFriends {
Expand Down Expand Up @@ -93,7 +93,7 @@ query DroidFriends {
}
```

> **Note**
> [!NOTE]
> The selection in the client's operation (`DroidFriends` in this example) against an annotated field with a selection in its `@materializer` can be **any valid selection** against the type of the annotated field, which include selections of nested fields that themselves have `@materializer`, with or without selections.

If anywhere in the selection any field is a list then the annotated field must have a type that is a list of the single field.
Expand Down Expand Up @@ -121,5 +121,4 @@ stepzen request -f operations.graphql --operation-name=DroidFriends -H Authoriza
stepzen request -f operations.graphql --operation-name=HumanFriendsNames -H Authorization:
```

> **Note**
> `-H Authorization:` removes the authorization header automatically added by `stepzen request` to demonstrate the fields are public.
> [!NOTE] > `-H Authorization:` removes the authorization header automatically added by `stepzen request` to demonstrate the fields are public.
2 changes: 1 addition & 1 deletion reshape/subset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ stepzen request -f operations.graphql --operation-name=Human -H Authorization:
stepzen request -f operations.graphql --operation-name=Version -H Authorization:
```

> **Note** > `-H Authorization:` removes the authorization header automatically added by `stepzen request` to demonstrate the fields are public.
> [!NOTE] > `-H Authorization:` removes the authorization header automatically added by `stepzen request` to demonstrate the fields are public.
8 changes: 6 additions & 2 deletions routing/supplies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ based upon a condition against its field arguments.
## Example

The abstract field in `Query` is:

```graphql
expected(id:ID):Delivery
```

which given a tracking identifier returns when a package is expected.

It is supplied by three fields, each with a condition.
Expand All @@ -29,7 +31,8 @@ It is supplied by three fields, each with a condition.
tyd(id: ID!): ToYourDoor
@supplies(query: "expected" if: {src: "$contains(id, /^TYD-/)", language: JSONATA})
```
> **Note**

> [!NOTE]
> Implementation of the fields (`@rest`) have been omitted for brevity.

The script `src` must be ECMAScript 5.1 or JSONata and the field's arguments
Expand All @@ -42,11 +45,12 @@ Thus in this example if the tracking identifier starts with `FP-` a call
is made to the FastPackage REST api, if it starts with `ROS-` a call to
the `RainOrShine` REST api is called, `TYD-` a call to the To Your Door API otherwise no call is made.

> **Note**
> [!NOTE]
> The supplying fields can have any implementation, FastPackage could
> be a GraphQL endpoint while RainOrShine a database query.

## Try it out

Login to your StepZen account, deploy the schema and then issue requests.

```shell
Expand Down