Giter Site home page Giter Site logo

Comments (3)

mathewbyrne avatar mathewbyrne commented on July 16, 2024 2

I think Position is mostly intended for use in error messages. I would imagine that if you wanted to use gqlparser to achieve this you would parse the query, then programatically remove the expect directive from the AST before outputting back as a string. Is that not possible?

from gqlparser.

robojones avatar robojones commented on July 16, 2024

Thanks @mathewbyrne
I think it would be possible to use ast.Dump() to output the modified AST as a string.

func Dump(i interface{}) string {

The problem with that solution is that it would remove the original formatting.
If the API I am testing returned an error with a position attached to it, it would be near to impossible for me to map it back to the original source file position.

The only way I can think of to get the correct original error location would be to parse the original and the generated query and then walk through both ASTs. This seems like an awkward solution.

Edit:
Just noticed that ast.Dump() is something completely different xD
Is there a method to convert the AST back to the normal string format or do I have to write my own?

from gqlparser.

robojones avatar robojones commented on July 16, 2024

I'm just going to do it that way now. Thanks again @mathewbyrne for the idea.

from gqlparser.

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.