GithubHelp home page GithubHelp logo

Fragment usage about agoo HOT 17 CLOSED

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024
Fragment usage

from agoo.

Comments (17)

ohler55 avatar ohler55 commented on June 2, 2024

Fragments are supported. There is a test in test/graphql_test.rb named test_post_fragment.

I can look into why you example doesn't work though. It might take a couple of days before I can get to it though.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

Started looking at this today. I am not able to reproduce the issue so I suspect there is something different about the request. Can you tell me what the HTTP POST request looks like or what the content type of the request is? Is it application/graphql?

from agoo.

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024

Good afternoon,

We are working to provide you a reproducible example.
Meanwhile, this is the request that we are sending:

Request URL: http://localhost:6464/phrases
Request Method: POST
Status Code: 200 OK
Remote Address: 127.0.0.1:6464
Referrer Policy: strict-origin-when-cross-origin
accept: application/json, multipart/mixed
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 269\n
content-type: application/json
Host: localhost:6464
Origin: http://localhost:6464
Referer: http://localhost:6464/iql.html
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Sec-GPC: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
{"query":"\nfragment Phrase on Phrase {\n code\n usages\n starting_english_phrase\n is_system\n rank\n}\n\nquery getPhrases($filters: PhrasesInput) {\n phrases(filters: $filters) {\n ...Phrase\n }\n}\n","variables":{"filters":{}},"operationName":"getPhrases"}

and this is the response that comes:

{"data":{"phrases":[{},{},{},{},{},{}]}}

I checked the test that you mention, on the example with fragments you are using application/json, but in any cases we tried with application/graphql and it doesn't really help.

I'm attaching some postman requests to demonstrate the issue:
Screenshot from 2021-05-31 11-26-10
A valid graphql call
Screenshot from 2021-05-31 11-27-03
Same but with fragment instead
Screenshot from 2021-05-31 11-27-24

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

That helps. I'll try testing with JSON instead of GraphQL content.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

That helped a lot although I would have expected to see an error on the fragment calls. There is a bug in the JSON parser which I will fix. Please try the json-parser-fix branch.

from agoo.

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024

Thank you for your time for having a look on this issue.

Regarding content-type: application/graphql, I think there's another bug to it:
The first image with "name not provided" "parse error" is the outcome of trying to send a request with application/graphql.

And secondly, when I try to introspect the schema with this library graphqurl
and execute the following command gq <url> --introspect > schema.json it fails with unsupported content type.

Noticeably, if I modify the command to export json rather than schema, it works, but then again I have to explicitly indicate the content-type:
gq <url> -H 'content-type: application/json' --introspect --format json > schema.json

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

I'm not familiar with the gq tool so I'm not sure what the --introspect does but I will check it out and run some tests to get it all working.

I can't tell from the first image what the content was of the call. With that I could probably figure out what is going on.

from agoo.

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024

ah, the content was the same as on other images, with or without fragment usage the error will be the same.

--introspect basically runs an IntrospectionQuery that downloads a schema.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

I assume you mean the the same but in graphql format and not JSON, right?

from agoo.

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024

yes indeed. it should download a SDL schema, instead of JSON

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

To nights homework for me will be to try out gq and see what is sent.

from agoo.

alexander-r-jaimy avatar alexander-r-jaimy commented on June 2, 2024

The following command:
gq https://graphqlzero.almansi.me/api --introspect > schema.graphql
downloads a schema. This is useful for generating typescript types to use in frontend frameworks - more automation

and then this schema is feed to graphql-codegen that will generate the types we need

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

BTW, with Agoo you can also download the schema with http://localhost:3000/graphql/schema if the GraphQL endpoint is http://localhost:3000/graphql.

Can graphql-codegen be configured to generate ruby code as well?

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

The reason for the error in the first block is that just changing the header with gq does not change the content. The content is still JSON but the header claims to be graphql so Agoo attempts to parse as graphql and fails. Digging in to more but want to give you some preliminary feedback.

I'll have to try something else beside gq for introspect. Agoo is returning the expected result but gq is refusing to read it for some reason. I'll try curl with the same query and see what happens but that will be tomorrow.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

I haven't been able to reproduce the gq introspect issue. Curl works fine with the same query as does graphiql. I did uncover another issue with graphiql. A comment only request caused a crash which has been fixed. Just refresh the branch.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

I plan on releasing these changes if I don't hear back from you by tomorrow.

from agoo.

ohler55 avatar ohler55 commented on June 2, 2024

Released and closing.

from agoo.

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.