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

Schema File #19

Open
alexsteinerde opened this issue Jun 13, 2018 · 3 comments
Open

Schema File #19

alexsteinerde opened this issue Jun 13, 2018 · 3 comments

Comments

@alexsteinerde
Copy link
Member

Hey,
It would be great to have the ability to provide a schema file to the server and start it with the file content.
Or is this already possible just not listed in the readme?
Thanks
Alex

@daviskoh
Copy link

Would be interested in something like this as well.

Personally, I think that a good flow would be to parse a schema.graphql file(s) and codegen a usable Graphiti Schema type in Swift similar to how projects like apollo-tooling for clientside Swift and gqlgen for Go do. Resolver handlers would be stubbed out with proper closure arguments that consume generated Swift types as well.

What I've seen from libs that map GraphQL to static langs like Swift and Go that have granular types (like a uint32) is that such mapping may need some extra implementation logic. Maybe using something Schema Directives, though I'm not sold on it. For example:

Type Example {
  field: Int @Swift(type: "UInt32")
}

☹️

Ultimately, it would obviously be the generated Swift code itself that is consumed by something like a server and not the schema.graphql file(s).

What I am talking about would be a CLI and may be a separate project. 🤔🤷‍♂️

@johndpope
Copy link

johndpope commented Sep 5, 2019

This could be quite some work - but I've created a graphql file parser
https://github.com/johndpope/antlr-graphql-playground

To use this - you need to get head around antlr / lexars / parsers. (this is something I'm yet to master - although with enough perserverance this is definitely the right path.)

Fortunately - someone's already done some hard yards here.
This graphql-java repo is very polished - but there maybe older commits with some bare bones code that could be decyphered. I've used the same g4 grammar files.
https://github.com/graphql-java/graphql-java

I may take another look at this if there's interest.

Screen Shot 2019-09-05 at 4 00 37 pm

UPDATE
It maybe simpler to use something like this to parse graphql file
https://github.com/prisma/vscode-graphql/blob/master/grammars/graphql.json

@alexsteinerde
Copy link
Member Author

Technically it is not possible to scan a schema.graphql file and use reflections to access necessary resolvers, types, etc. yet. Swift doesn't allow this in it's current implementation.
But I think @daviskoh code-gen idea is the best way to go if we want to have a schema file as the single source of truth, I think.

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

No branches or pull requests

4 participants