Comments (7)
I may still not fully understand what you're trying to do. 😅
I think you are writing a graphql-server (using sangria
; with Scala) which is used by the frontend (in the Browser; not Scala). You also said that you want to generate/derive the graphql schema from some other schema like a grpc
definition or database schema.
If this is the case this plugin sadly cannot help you much right now. But sangria
already has some ways to eliminate boilerplate code:
- sangria provides a nice DSL to define schemas and as long as you have a way to access a structured form of a
grpc
definition or database schema, it should be possible to write code that converts that into asangria
schema definition. (I heard Twitter does this but I haven't seen it myself; ping @sachee). - When you already have case classes somewhere (manually written or generated by some other plugin), you can use
sangria
macro derivation to derive the graphql schema from it. - When you already have a graphql schema (SDL), you can use
sangria
schema materialization to generate code stubs for it. So if you find a tool that converts yourgrpc
definition into a graphql schema (SDL), this might be useful.
Both of the mentioned options directly use sangria
. The plugin here (sbt-graphql
) isn't needed for that. But it is useful to do other things:
- Generate code if you're using Scala as a client to a graphql API
- Write a sangria-schema as SDL to a file (for code-review)
- Validate a sangria-schema against some graphql SDL (e.g. to match a "SDL-spec" or to check for breaking changes)
edit: I also don't understand what this has to do with graphql-java
, sorry 😕
from sbt-graphql.
Hello, PRs are always welcome. 🙂
Could you describe your use-case (or goal) for the graphql-java support you want to add? Maybe there's already a way to do it.
from sbt-graphql.
I just want to convert schema to scala case class, because writing two much case class are boring. In theory, schema standards are the same in different implementations of graphql, so they can already support? I'm not sure, because i found a issue has open #19
from sbt-graphql.
You can already generate case classes for a given graphql schema (on the client-side). In your case the schema would be pulled from a graphql-java server. Check out the Code Generation part of the readme.
The issue you linked is similar but instead of generating the client-side code they want to generate a sangria-server from a given schema. I assume you don't need that because you already have a graphql-server (using graphql-java).
Hope this helps 🙂
from sbt-graphql.
sry ,It may not be described clearly, but I think I also need the server code ,that is data response to frontend.
1.fetcher response
ProjectInfo(......) or grpc Dto ProjectInfoDto
2.server schema like this
type ProjectInfo { id: HashId! name: String! logo: String @option createdAt: DateTime! }
3.then i need write case class for response, this is what i want to auto generate
case class ProjectInfo( id: Long, name: String, logo: Option[String], createdAt: ZonedDateTime)
That is a pure back-end service, exposing a /grqphql interface to the frontend.
I hava two cases by Repository implements
1.one case is (dao call grpc)
convert ProjectInfoDto => schema (graphql SDL ) when grpc Dto was exists, i want no longer need to write SDL
or 「grpc message schema => schema (graphql SDL )」(because this graphql service only as a API, Dto is the same as SDL)
2.another case is (dao call database)
schema => case class
or if i generate code from datebase table, i can no longer write SDL too.
case class => schema
from sbt-graphql.
I forgot to link to this sangria
issue where its creator talks about the schema materialization: sangria-graphql/sangria#381
from sbt-graphql.
Okay, thank you, 😯maybe Sangria can do this,but i write graphql-server not Sangria,
from sbt-graphql.
Related Issues (20)
- Code generation for unions is flawed HOT 1
- codegen support for 'URI' scalar type HOT 1
- Yet another trouble getting codegen to work HOT 2
- Code generation - The output directory for generated files should be configurable. HOT 1
- Missing Sangria Custom Scalars In Schema Generation HOT 1
- Fix .scalafmt.conf
- Fragment code generation is broken for union types HOT 3
- Stable ordering of output HOT 3
- Add toString to graphqlCodegenStyle, Json HOT 2
- [question] Can I annotate generated classes? HOT 1
- Schema generation from Introspection HOT 5
- How to reorder execution of sbt-graphql plugins? HOT 9
- Code generation question HOT 5
- Examples for common use-cases HOT 5
- Multiple schemas generation, is it possible? HOT 8
- Only regenerate Scala files from GraphQL schema if schema changes HOT 1
- Move to github actions HOT 2
- Weird published version v0.1.6 HOT 2
- Question about code generation issue in test phase HOT 6
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 sbt-graphql.