Comments (29)
@phated I understand what you mean, this way can really solve the problem that ide can't recognize the type. After I am busy with the work at hand, I will study the feasibility. 😁
from async-graphql.
@kellpossible the common practice is just to use a tool against your development environment and check in the schema.graphql
. I use https://www.npmjs.com/package/graphql-cli/v/3.0.14 (make sure to use the older version because the new one removed features)
from async-graphql.
@kellpossible the common practice is just to use a tool against your development environment and check in the
schema.graphql
. I use https://www.npmjs.com/package/graphql-cli/v/3.0.14 (make sure to use the older version because the new one removed features)
I think it's better that way.
from async-graphql.
Do you want to generate some framework code through GraphQL Schema DSL?
from async-graphql.
Hi, tks for the quick reply.
That could work. the point is, most of my implementations today are in JS. I decided to use the DSL notation to abstract the graphQL implementation. So yes a code generator would definitely help and be very useful to a broader audience.
from async-graphql.
I thought about it, in fact, rust has another library to do this, https://github.com/davidpdrsn/juniper-from-schema, but it does not support async-graphql. The biggest problem is that this type of code generation will create new types, but these types of IDEs do not recognize them, so they cannot be automatically completed. I think this increases the difficulty of writing code, so I am still considering whether I really need to implement this. 😁
from async-graphql.
Instead of using macros to generate the rust code, there could be a command line tool that outputs the rust code (like diesel-cli
does for the database). I believe the new parser work that @sunli829 did could be used to support that tool.
from async-graphql.
You mean a tool that - given a GQL Schema and access to your business logic - generates some boilerplate for your api before compilation?
from async-graphql.
Thank you. For the context. I built a GraphQL UI designer - it generates SDL code. Ideally would love to have it generate RUST code for the same model. Which brings me to two questions:
- Why can't rust read the SDL like javascript does? Is there any limitations in the language?
- Well, a generator can be written in any language - if you highlight the patterns, I could even write it in JS. Remember I already have the SDL parser.
Cheers
from async-graphql.
What I understand is that you have a tool that can automatically generate GraphQL code for js, including the implementation of solving functions. Now you want to generate rust?
from async-graphql.
GraphQL UI designer contains the definition of the data source, so you can generate the entire code, similar to hasura? 😁
from async-graphql.
The tool goes from UI UML like models -> GraphQL SDL
from there:
hasura takes that SDL and creates a persistent implementation on the database
my own JS graphql server (which has nothing special), takes the SDL and creates a volatile implementation.
Now, I would love to see you implementation read the SDL, but it doesn't at this point.
Therefore two options:
- have you implement the functionality - may take some time
- create a code generator (you mentioned it) - the point here is that this generator doesn't necessarily have to be built in rust. so using some of the opensource projects I already build, we could quickly implement a "prototype"
from async-graphql.
I have seen the code of graphql-shorthand-parser, if I have not misunderstood, it is a GraphQL Schema parser, and your purpose is to be able to use this parser result (AST) to generate rust code, is that true? 😁
from async-graphql.
If I understand correctly above, there is a small problem here. If I hope that the tools from SDL to Rust code
can be used as rust macros in the future, js cannot do this.
from async-graphql.
Sorry, I just understood the meaning of SDL, which is Schema Definition Language.
from async-graphql.
No worries, I think they call it IDL but anyways.. glad you got it
On my side, I am really not familiar with Rust... what are macros?
from async-graphql.
There is a syntax in javascript, @ annotations
, also in python and java. The rust macro can do the same thing, the difference is that it is completed at compile time.
from async-graphql.
I see. that's actually one of the "missing" features I identified up on the thread. Glad it's there, then.
Back to our discussion. in your opinion, is it worth supporting SDL in your Rust implementation?
from async-graphql.
I think it's worth it. After all, some developers like "Schema first", so I'm already thinking about how to implement this. 😁
from async-graphql.
And when I started to do this, I thought I would finish it soon.
from async-graphql.
When/if you implement it..
I found this library - https://github.com/kevinmehall/rust-peg
Here are my grammar files - https://github.com/orefalo/graphql-shorthand-parser/tree/master/src
Cheers
from async-graphql.
Thank you very much. 🍺
from async-graphql.
Alternatively, some way to export the Schema in the schema format at build time would be nice.
from async-graphql.
Export sdl for the client?
from async-graphql.
Yes, I haven't used graphql before, this is my first time, so forgive me if I'm missing something, I was thinking exporting the schema definition schema.graphql
to be consumed by the client at build time. That way there is still only a single definition. Perhaps this would be easier to do than implementing an SDL parser, and generating the schema for the server from that?
from async-graphql.
@phated thanks ooh okay that does sound good, so the idea is that using the CLI tool you can pull the schema from the graphql server/api and updates the schema file that way? A pity it is an older version.
from async-graphql.
So...is it currently possible to use async-graphql
with the schema first
approach? I couldn't find a way to parse and use a schema file.
from async-graphql.
So...is it currently possible to use
async-graphql
with theschema first
approach? I couldn't find a way to parse and use a schema file.
https://docs.rs/crate/codegen-for-async-graphql/0.2.6
I haven't used this, but it seems to be schema first.
from async-graphql.
Ah...ok, so i have to use an external lib for that. Thanks for the info.
Yes, that is schema first. Just for others reading this, it is working, but has a few caveats. It currently is not able to generate code for a required array with required elements, i.e. [Branch!]!
(see Issue #5).
from async-graphql.
Related Issues (20)
- Access the value of "variable" arguments (`Value::Variable`)
- Has anyone does any benchmarks because im getting extremely poor results and I do not know why? HOT 8
- Get mutable referenece to the global data defined in the `Context` or `Schema` HOT 1
- Confusing `unused_mut` warning in `#[Object]` HOT 8
- How to handle both directions of one-to-many relation in federated graph
- Question: How to get server to send ping messages on subscriptions? HOT 2
- Parsing multiple operations in a file HOT 1
- Non nullable variables should allow default values HOT 3
- Object with single skipped field but with ComplexObject HOT 2
- As using proxy type
- Using flatten inside an impl with no other fields causes a compile error
- Subscription with MPSC receiver in context data
- Reduce clippy noise from #[Object] macro HOT 2
- Guard trait lifetime HOT 1
- Using generics with both SimpleObject and InputObject as field in output type fails HOT 1
- Subscription Authentication
- Stack overflow after upgrade to 7.0.2 HOT 3
- Does async-graphql validate responses?
- Error reading data from ExtensionContext after upgrade to 7.0.3
- Create a general error formateer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async-graphql.