REST bindings (tutorial)

Use bindings to supply additional information to a query at runtime. In this example we have:

  • An API endpoint that accepts a status field to filter a list of applications
  • A query named applications
  • An application that supplies data to the bindings of the query
26442644

 


 

Creating a binding

We can create a binding named status with a default value of all.

19681968

 


 

Using a binding

Using handlebars the binding can be referenced throughout the query in the following places:

  • URL
  • Params
  • Headers
  • Body
  • Transformer

 

Params example

The binding can be used as the value of a param of the same name. While the name can be shared it is not required.

20202020

 

Headers example

The binding can be used as the value of a header of the same name. As above the binding and header name may or may not be shared.

19261926

 

Body example

The binding can be used in any part of the request body. e.g. as the value of a JSON field.

19561956

 


 

Supplying data to a binding

In our application we have the following structure:

488488

 

Form: Status Form

The form will hold the value of our selected status. This is the top-level component so that the value can be accessed by components nested underneath.

  • Type: Create
    • While this form does not create anything, this option is required to indicate that the input schema (the bindings) should be used rather than the schema returned by the query.
    • Update may also be used to the same effect.
  • Schema: applications
    • The input schema of our REST query
530530

 

Options Picker: Picker

We use an options picker in the form to provide our possible status values.

506506 22982298
  • Field: status
  • Adds the selection to the form under the name status
  • Options source: Custom
    • Custom options are specified using the Define Options drawer

 

Data Provider: Applications provider

We use a data provider to run the REST query

512512
  • Data: applications
    • The REST query

To link the query bindings to the form we use the bindings drawer:

33563356

The value of the binding is

{{ Status form.Fields.status }}

Which represents the status field in our form.

 


 

Conclusion

We are now able to:

  • Specify a binding used in a REST query
  • Specify where the value of that binding will be used using handlebars
  • Create an application that supplies data to the binding and runs the query

 


Did this page help you?