apigee-127 / bagpipes

Less code, more flow. Let's dance!
MIT License
47 stars 30 forks source link

Emit overrides input of next fitting #24

Closed Celadora closed 7 years ago

Celadora commented 7 years ago

I have a simple pipe:

  getTruncatedThing:
    - emit:
        fields:
          - id  # tells the "getThing" service to truncate the response to only the id field
    - getThing

  getThing:
    name: getThing
    type: user
    input:
      name:
        value: .request.swagger.params.name.value[0]
        default: 'foo'

When the getTruncatedThing pipe is played, the "name" input is omitted from the getThing context. I expect this behavior for amend, but emit doesn't seem like it should also override the input of the next fitting.

Celadora commented 7 years ago

The error we had was in two places.

First the 'getThing' fitting played after 'emit' is not exactly the same as the fitting defined in config. Instead it is the fitting that is loaded, but without the fittingDef provided by the config. To solve this we just renamed getThing under the 'name' field to get_thing.

Second, the order of our schema is in reverse, it should have been:

      getThing:
        name: get_thing
        type: user
        input:
          fields: .output.fields

      getTruncatedThing:
        - emit:
            fields:
              - id
        - getThing

This is because getTruncatedThing needs to have the definition of getThing before it can be processed.

Thank you for your time.

theganyo commented 7 years ago

Thanks for the follow up! Glad you got things running.