GithubHelp home page GithubHelp logo

about graphql-Java about sbt-graphql HOT 7 CLOSED

muuki88 avatar muuki88 commented on May 31, 2024
about graphql-Java

from sbt-graphql.

Comments (7)

felixbr avatar felixbr commented on May 31, 2024 1

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 a sangria 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 your grpc 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.

felixbr avatar felixbr commented on May 31, 2024

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.

jxnu-liguobin avatar jxnu-liguobin commented on May 31, 2024

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.

felixbr avatar felixbr commented on May 31, 2024

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.

jxnu-liguobin avatar jxnu-liguobin commented on May 31, 2024

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.

felixbr avatar felixbr commented on May 31, 2024

I forgot to link to this sangria issue where its creator talks about the schema materialization: sangria-graphql/sangria#381

from sbt-graphql.

jxnu-liguobin avatar jxnu-liguobin commented on May 31, 2024

Okay, thank you, 😯maybe Sangria can do this,but i write graphql-server not Sangria,

from sbt-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.