Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alias problems by unaliasing queries we are sending to sub schemas #411

Merged
merged 3 commits into from
Oct 4, 2017

Conversation

freiksenet
Copy link
Contributor

@freiksenet freiksenet commented Oct 4, 2017

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change

@stubailo stubailo merged commit 40dac0d into master Oct 4, 2017
@stubailo stubailo deleted the fix-alias-problems branch October 4, 2017 23:29
@pozylon
Copy link
Contributor

pozylon commented Oct 5, 2017

@freiksenet @martijnwalraven

This query results in the correct response now:

{
  orders {
    itemTotal: total(category: TAXES) {
      amount
      currency
    }
  }
}

But as soon as you add a second alias with the same field, errors pop up, but only when using arguments.

This one runs perfect still:

{
  orders {
    itemTotal: total {
      amount
      currency
    }
    taxesTotal: total {
      amount
      currency
    }
  }
}

But that one here does not:

{
  orders {
    itemTotal: total(category: ITEMS) {
      amount
      currency
    }
    taxTotal: total(category: TAXES) {
      amount
      currency
    }
    paymentTotal: total(category: PAYMENT) {
      amount
      currency
    }
    deliveryTotal: total(category: DELIVERY) {
      amount
      currency
    }
    netTotal: total(category: NET) {
      amount
      currency
    }
  }
}

Response is:

{
  "data": null,
  "errors": [
    {
      "message": "Fields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.\nFields \"total\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "orders"
      ]
    }
  ]
}

And this is the result when firing the same query directly to the proxied server:

{
  "data": {
    "orders": [
      {
        "itemTotal": {
          "amount": 5958,
          "currency": "CHF"
        },
        "taxTotal": {
          "amount": 441,
          "currency": "CHF"
        },
        "paymentTotal": {
          "amount": 0,
          "currency": "CHF"
        },
        "deliveryTotal": {
          "amount": 0,
          "currency": "CHF"
        },
        "netTotal": {
          "amount": 5958,
          "currency": "CHF"
        }
      },...

Ugly workaround at the moment:

{
  order {
    total(category: TAXES) {
      amount
      currency
    }
  }
  taxes: order {
    total(category: ITEMS) {
      amount
      currency
    }
  }
}

@freiksenet
Copy link
Contributor Author

Thanks! I suspected this will break. I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants