-
Notifications
You must be signed in to change notification settings - Fork 73
SDL support #55
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
Comments
We don't have support yet. We're open to contributions! |
@paulofaria - is this still open? |
@dfperry5 Yeah, SDL support is still an outstanding area for improvement. |
@NeedleInAJayStack - I'm interested in trying this out. Do you happen to know where in https://github.com/graphql/graphql-js they read in the SDL stuff? I'll keep looking through it myself. |
@dfperry5 That would be awesome! I'm actually not too familiar with where SDL stuff lives in graphql-js. I believe it is built into the lanugage parser, and that our repo already has some of the tokens required to interpret SDL. But I imagine there are still some incompatibilities to figure out. Thanks! |
hey yall, i wrote a parser for graphql that supports everything needed for client side parsing in swift, meaning it parses much of what's available in the schema https://github.com/remind101/AutoGraphParser/ . this was after dealing with some frustration with the official C libgraphqlparser which wasn't being kept up-to-date (still on the 2016 spec actually), but what has come out of it i think is very easy to read and maintain (see Language.swift). anyway, my next plan which i want to execute on soon is full schema parsing of the entire language. after that I would actually very much want this to be inherited / integrated / subsumed by GraphQLSwift and i'd be happy to help maintain it, i have a vested interest in it. let me know how this all sounds, would love to collaborate here :) |
Hey, @rex-remind101! This sounds awesome. Love that you're using swift-parsing. I'm open to incorporating the parser in the library and implementing SDL support. I didn't have time to look, but what is the status in regards to testing? |
there's a grip of unit tests. i'm not sure how complete they are, however, we use this parser to support our client code-generator on our app that is very very large with a lot of diverse graphql queries to say the least. also, the codegen is tested across queries in a somewhat diverse suite of schemas too (which implicitly tests the parser) https://github.com/remind101/AutoGraphCodeGen/tree/main/Tests/Resources btw, if it yall are happy to integrate it i think it would be nice to have the parser as its own lib under the GraphQLSwift moniker. that way users could use it for other cases (like our codegen lib). I'm also hopeful that as the C++ interop story aligns on swift we can even have this as an option more universally for other languages via FFI etc too :) |
Yep! All of this sounds good to me, cc @NeedleInAJayStack. Guess we also have to see how this would fit with the SSWG incubation process. @adam-fowler, is there any rules regarding the maturity level of package dependencies? Would splitting up the parser dependency require it to be at the same maturity level as the main package? |
Yeah, it looks very cool! Thanks for sharing @rex-remind101! I had a few questions as I reviewed:
Overall, I'd love to see more Swift client functionality in the GraphQLSwift org. If we're imagining this as a server-side tool, we probably just need to do a little thinking about where it fits in. Thanks again for sharing, and excellent work! |
that is accurate as of current because the immediate need was to service a code generator on the client side. but i want to expand it to include parsing of the entire language so it can serve both client and server side.
looking a bit over it it seems to more or less serve the same purpose. one core difference I notice is that a
I think the end-result of the parser being able to cover the whole GQL language could be used for both client and server. also after the fact i think i could draw from my experience to add a client library too, the existing one works well enough but I've wanted to do a bit of a rewrite of parts especially given async-await in swift. i could maybe redirect work towards GraphQLSwift org instead depending on technical direction :) |
Cool, thanks for your take on those questions. Overall, I'm on board with bringing this package into the GraphQLSwift org. However, I'd hesitate to replace the GraphQL parser with this implementation (or really any other one). The swift GraphQL package as a whole is basically a direct port of the graphql-js reference implementation (see the graphql-js parser for similarities). This approach has some significant benefits:
It also brings some downsides, mainly that it doesn't always take advantage of some unique Swift language features like ResultBuilders, strong typing, etc. The approach so far has been to add those features on top of GraphQL in separate packages like Graphiti. If either of you think I'm off-base on this, please let me know. Aside from that, I definitely think having this parser as a separate package seems totally reasonable, whether under the GraphQLSwift org or your own. I really do like the technical approach, and think it could be very useful in building GraphQL utilities in Swift! |
I mostly agree with all points, @NeedleInAJayStack. Since this issue is related to SDL support, I wonder what's missing from the existing parser to support it? Also how would SDL support look like with Graphiti, for example? Regarding client libraries. I would love to create a client library, maybe based on Swift macros? I believe there is something we can do to make it possible to hand the client API a Graphiti schema and be able to get code completion and type safety (build errors) when writing result builder queries based on the types defined in the schema? |
ok, that logic is reasonable for maintaining the current parser. i still wouldn't mind bringing AutoGraphParser under the GraphQLSwift moniker though i'd still intend it to be full fledged GQL parser (at some point in the near future) which i'm not sure if that would create some confusion for people? possibly the intention would be if someone wants something very swifty use the AutoGraphParser (though maybe we change the name then too)?
in terms of a client library i'm not sure how you intend on fitting in Graphiti schema, but i think any sufficient client library would need to be able to support backend languages other than swift too meaning it would need to perform introspection directly for schema verification. (might be time to move that topic to another conversation though) |
I think the GraphQL Parser already supports SDL. Check out this test. It doesn't really check that the SDL parses correctly though, so there might be some edge cases to track down. The package is definitely missing some standard utilities around printing Schemas to SDL, and some SDL validation rules.
I think this one's a bit more tricky. I'll spend a little time over the next few days looking into it and get back to you. |
Great, @NeedleInAJayStack! Looking forward to it. |
Question
Support executable schema based on schema definition language.
The text was updated successfully, but these errors were encountered: