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

Invalid Path Returns for Errors in Record Fields #4286

Closed
DimuthuMadushan opened this issue Mar 30, 2023 · 1 comment · Fixed by ballerina-platform/module-ballerina-graphql#1340
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Milestone

Comments

@DimuthuMadushan
Copy link

Description:
Consider the following graphQL service:

import ballerina/graphql;

type Profile record {|
    string name;
    int age;
    Address address;
|};

type Address record {|
    int number;
    (string|error)[]? street;
|};

service /graphql on new graphql:Listener(9090) {

    resource function get profile() returns Profile {
        return {
            name: "Harry",
            age: 20,
            address: {
                number: 221,
                street: ["bakers", error("invalid!"), "main"]
            }
        };
    }
}

It returns the following response if we query the field street.

{
  "errors": [
    {
      "message": "invalid!",
      "locations": [{"line": 7,"column": 7} ],
      "path": ["profile", 1]
    }
  ],
  "data": {
    "profile": {
      "name": "Harry",
      "age": 20,
      "address": {
        "number": 221,
        "street": null
      }
    }
  }
}

Here, the error path is incorrect. It should be ["profile", "address", "street", 1]. It seems the record field names are missing in the path.

@github-actions
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/PCM Protocol connector packages related issues Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants