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

The engine should raise a syntax error when a complex type is specified instead of one or more of his leaves #109

Closed
tsunammis opened this issue Jan 29, 2019 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tsunammis
Copy link
Contributor

The engine doesn't raise an error when a complex type is specified as a leaf. We can't have a complex type used as a leaf.

e.g

type Query {
  mobility: Mobility
}

type Mobility {
  tramStations(offset: Int, limit: Int): [TramStation]
}

type Location {
  latitude: Float
  longitude: Float
}

type TramStation {
  id: String
  name: String
  line: String
  location: Location
}

This following query returns a dict for the location property instead of a syntax error.

query {
  mobility {
    tramStations {
      id
      name
      location
      line
    }
  }
}

returns

{
  "data": {
    "mobility": {
      "tramStations": [
        {
          "id": "P2",
          "name": "Place d'Arc",
          "location": {},
          "line": null
        },
        {
          "id": "P4",
          "name": "Patinoire",
          "location": {},
          "line": null
        },
        {
          "id": "P17",
          "name": "Pont de l'Europe",
          "location": {},
          "line": null
        }
      ]
    }
  }
}
  • Tartiflette version: 0.3.4
  • Python version: 3.7.1
  • Executed in docker: No
  • GraphQL Schema & Query: c.f above
  • Is a regression from a previous versions? No
@abusi
Copy link
Contributor

abusi commented Jan 29, 2019

Hum, i'll look at the spec, to found the correct error to raise here. But I think it's pretty logic, you ask for an object whithout asking for a field you get an empty shell ;). Clearly here you have the default value of a non explored object. It should be pretty straight forward to detect and raise error during parsing.

If you're out of a field without child and you're not a leaf -> error.

@abusi abusi added the bug Something isn't working label Jan 29, 2019
@abusi abusi added this to the road-to-v1 milestone Jan 29, 2019
@abusi abusi self-assigned this Jan 29, 2019
@abusi
Copy link
Contributor

abusi commented Jan 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants