Code Monkey home page Code Monkey logo

Comments (4)

swolchok avatar swolchok commented on May 5, 2024 1

I think this was fixed by #52.

from libgraphqlparser.

schloerke avatar schloerke commented on May 5, 2024

I believe the errors are only associated with comments

# correct
"{\n  name\n}" %>% graphql2json()
{"kind":"Document","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":1}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} 
# incorrect. Document should start on line 2
"#asdfasdf\n{\n  name\n}" %>% graphql2json()
{"kind":"Document","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":11}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} 
# incorrect. Document should start on line 2
"#asdfasdf   \n{\n  name\n}" %>% graphql2json()
```json
{"kind":"Document","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 1,"column":14}, "end": {"line":3,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 2,"column":3}, "end": {"line":2,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} 
# correct
"\n \n  \n{\n  name\n}" %>% graphql2json()
{"kind":"Document","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 5,"column":3}, "end": {"line":5,"column":7}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 5,"column":3}, "end": {"line":5,"column":7}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} 
# incorrect. Name should start on line 6
"\n \n  \n{\n#asdf\n  name\n}" %>% graphql2json()
{"kind":"Document","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"definitions":[{"kind":"OperationDefinition","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"operation":"query","name":null,"variableDefinitions":null,"directives":null,"selectionSet":{"kind":"SelectionSet","loc":{"start": {"line": 4,"column":1}, "end": {"line":6,"column":2}},"selections":[{"kind":"Field","loc":{"start": {"line": 5,"column":9}, "end": {"line":5,"column":13}},"alias":null,"name":{"kind":"Name","loc":{"start": {"line": 5,"column":9}, "end": {"line":5,"column":13}},"value":"name"},"arguments":null,"directives":null,"selectionSet":null}]}}]} 

from libgraphqlparser.

schloerke avatar schloerke commented on May 5, 2024

With the location information, should the list of information about the start or end position, have a GraphQL Class?

type Position {
  line: Int!
  column: Int!
}
type Location {
  start: Position!
  end: Position!
}

This would make the output something like:

...
"loc": {
  "kind": "Location",
  "start": {
    "kind": "Position",
    "line": 4,
    "column": 1
  },
  "end": {
    "kind": "Position",
    "line": 6,
    "column": 2
  }
}
...

Thank you for the help!

from libgraphqlparser.

schloerke avatar schloerke commented on May 5, 2024

There is also some odd length when looking at StringValues. The StringValue below should have a position of 1:10 to 1:18. Likewise, the overall Document positions are off.

"{name(id:\"Barret\")}" %>% graphql2json()
{ "kind":"Document",
  "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
  "definitions":[
    { "kind":"OperationDefinition",
      "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
      "operation":"query",
      "name":null,
      "variableDefinitions":null,
      "directives":null,
      "selectionSet": 
      { "kind":"SelectionSet",
        "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":26}},
        "selections":[
          { "kind":"Field",
            "loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":25}},
            "alias":null,
            "name":{"kind":"Name",
            "loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":6}},
            "value":"name"},
          "arguments":[
            { "kind":"Argument",
              "loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":10}},
              "name":{ "kind":"Name",
                "loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":9}},
                "value":"id"},
              "value":{"kind":"StringValue",
                "loc":{"start": {"line": 1,"column":9}, "end": {"line":1,"column":10}},
                "value":"Barret"}
            }
          ],
          "directives":null,
          "selectionSet":null
}]}}]} 

The same size query below has the correct positions

"{name(id:12345678)}" %>% graphql2json()
{"kind":"Document",
  "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
  "definitions":[
    { "kind":"OperationDefinition",
      "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
      "operation":"query",
      "name":null,
      "variableDefinitions":null,
      "directives":null,
      "selectionSet":{"kind":"SelectionSet",
        "loc":{"start": {"line": 1,"column":1}, "end": {"line":1,"column":20}},
        "selections":[
          { "kind":"Field",
            "loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":19}},
            "alias":null,
            "name":{"kind":"Name",
              "loc":{"start": {"line": 1,"column":2}, "end": {"line":1,"column":6}},
              "value":"name"},
            "arguments":[
              { "kind":"Argument",
                "loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":18}},
                "name":{"kind":"Name",
                  "loc":{"start": {"line": 1,"column":7}, "end": {"line":1,"column":9}},
                   "value":"id"},
                "value":{"kind":"IntValue",
                  "loc":{"start": {"line": 1,"column":10}, "end": {"line":1,"column":18}},
                  "value":"12345678"}
              }
            ],
            "directives":null,
            "selectionSet":null
}]}}]} 

from libgraphqlparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.