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

Support string queries #1

Closed
metalmatze opened this issue Jul 19, 2017 · 5 comments
Closed

Support string queries #1

metalmatze opened this issue Jul 19, 2017 · 5 comments

Comments

@metalmatze
Copy link

Hey! Thanks for creating that lib. I'm going to look into at once I'm more familiar with the basics of dart again. It's been a long time...

I want to learn about your approach to create the queries like this:
https://github.com/hourliert/graphql_client/blob/716ddcae1b33a7400c99dd89fc96a0a6b0a948a6/example/graphql_client_example.dart#L27-L39

IMO it's way better to use simple string queries, run them and after getting the response marshall them into the objects you'd like to work with.
What makes this so much better to work with, is the fact that you can actually write the queries in GraphiQL and just copy & paste them over into your code. This is just not possible with the current approach and thus probably error prone.

Cheers 🍻

@hourliert
Copy link
Member

hourliert commented Jul 19, 2017

Thanks for your issue.

This basic PoC is really inspired by https://github.com/shurcooL/githubql/blob/master/example/githubqldev/main.go#L44L97 which also uses "structs / instances" to define queries.

I didn't notice the fact that you could be much more productive by copying queries from GraphiQL into the code. I think a next step could be to use the https://pub.dartlang.org/packages/graphql_parser to transform a GQL query string into the internal library DSL...

I am going to add it to the roadmap!

@hourliert
Copy link
Member

Hi @metalmatze,

I have worked on this improvement this morning and it seems promising.
You could check a code example here.

I will be glad to have your opinion on that.

Cheers 🍻

@metalmatze
Copy link
Author

That looks really awesome and pretty easy to copy from GraphiQL. 👍
I'd like to test it myself, but time just doesn't allow for it right now. Maybe at the beginning of August I can manage to give it a try!

@metalmatze
Copy link
Author

Hey. I finally have time to check this out. Sadly this option to write the queries as a string was removed again, correct? 🤔

@hourliert
Copy link
Member

That is right. The previous implementation was working but was using mirrors. Since #7, I have remove mirrors usage to support flutter.

At the moment, you have to use the graphql_client.dsl documented here. A code example is available here.

I will create a code generator soon that converts GQL queries (as string) to the graphql_client.dsl. An issue is opened here and a doc detailing the code generator is available here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants