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

GraphQL support #214

Open
1 task done
glutengo opened this issue Mar 30, 2021 · 14 comments
Open
1 task done

GraphQL support #214

glutengo opened this issue Mar 30, 2021 · 14 comments
Labels
$$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ Feature New feature good first issue Good for newcomers question Further information is requested $500 https://www.jhipster.tech/bug-bounties/

Comments

@glutengo
Copy link
Contributor

Overview of the issue

Picking up from jhipster/generator-jhipster#4251 (comment)

I have decided to work on a GraphQL integration for nhipster in my master's thesis. I will start to work on this soon and I would like to hear the opinion of the developer team regarding the best approach on how to integrate my work in the jhipster ecosystem.

My initial idea was to create an own blueprint. This new blueprint would have generator-jhipster-nodejs as a dependency and add the new graphQL functionality where needed (using inheritance where possible). Would this be the right way to go? What other options are worth looking at? A PR in this project? A module rather than a blueprint?

Looking forward to hearing your thoughts!

Related issues

jhipster/generator-jhipster#4251

  • Checking this box is mandatory (this is just to show you read everything)
@ghost
Copy link

ghost commented Mar 30, 2021

Hi @glutengo , it's wonderful!
My opinion is to fork this blueprint and integrate the GraphQL support (merging with a PR).
The reason is that we already prompt a question for the database type, and you can add your graphql option.
Besides, NHipster uses TypeORM that easy could add graphQL support and is very similar to Hibernate (used in standard JHipster generator).
Last, but not the least, typeORM is already integrated in NestJS, that is the core nodejs backend framework of NHipster, so for nodejs backend implementation is advisable to use this blueprint, while for the client part you can use different templates to add in jhipster standard generator, or in NHipster blueprint (NHipster inherits the jhipster client templates and uses its own nodejs backend that works with its).

Here the configuration and the entity TypeORM main files of generated example app:

Here the blueprint prompt point of database choice:

However, I advice to wait the next NHipster 2.0.0 release (a beta will be published in the next days after #211 validation) and fork that main branch.

For any questions feel free to contact me, I'm the full NHipster contributor (the main founder and stream lead), so there will be wonderful to collaborate together!

@ghost ghost self-assigned this Mar 30, 2021
@ghost ghost added question Further information is requested good first issue Good for newcomers labels Mar 30, 2021
@glutengo
Copy link
Contributor Author

glutengo commented Mar 30, 2021

Hi @amanganiello90 thank you so much for your quick reply and thank you for all the pointers!

I have worked with NestJS and TypeORM in the past and the docs have their own graphQL section: https://docs.nestjs.com/graphql/quick-start

As far as I understand, using GraphQL would not be an alternative to using a certain database (type) like mysql or mongodb but it would rather be an alternative/addition to using REST, right?
So there should rather be an additional prompt which asks if the user wants to use graphQL instead of/in addition to REST. I was also thinking about a custom annotation on the concerned entity in JDL which is evaluated when code is generated based on the JDL schema.

Also thank you for offering your support, I will definitely get in touch again.

@ghost
Copy link

ghost commented Mar 30, 2021

Yes, the link section of NestJS that I have added in my comment is the same yours :)

However, when you customize the entity model template, you can define your service called by the controller REST api, so in my opinion when the user chooces the graphQL database automatically He will use your custom services and models (and you could add new questions after graphQL choice if there are other customization for the user).

For the JDL, if you need to specify an annotation to generate entity and services customization for GraphQL, you could use the jhipster standard databaseType. For example in NHipster I defined the sqlite value in devDatabaseType: https://github.com/jhipster/generator-jhipster-nodejs/blob/main/test-integration/samples/microservice-oauth2-jdl/.yo-rc.json

You could perform the same thing in JDL, and evaluate in the blueprint the different generation according the variable value.

Finally, you could give a look to the graphQL official jhipster module.

@ghost
Copy link

ghost commented Mar 30, 2021

@glutengo yes you are right, maybe it's more correct to add another question to chooce graphQL support in server subgenerator prompt because it enables api that you can use with all database types (sqlite, sql and so on).

However you will have customized templates for entity model, service and controller according your choice. These templates will be in entity-server subgenerator, called automatically by import-jdl command or entity command.

@glutengo
Copy link
Contributor Author

@amanganiello90 I agree and thanks for pointing out the existing jhipster module, that seems to be brand new and I had not seen that yet!

I was already typing and trying to make my case for not using the databaseType field but your latest comment shows we are on the same page now :)

@ghost
Copy link

ghost commented Mar 30, 2021

@glutengo you rock !!! 💯 ;)

@ghost ghost added the Feature New feature label Apr 6, 2021
@mraible mraible added $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ $500 https://www.jhipster.tech/bug-bounties/ labels Jun 8, 2021
@ghost
Copy link

ghost commented Jun 9, 2021

@glutengo go ahead with this issue. Thanks a lot @mraible for adding a bug bounty 💯. Markus is a great contributor 🥇

@glutengo
Copy link
Contributor Author

glutengo commented Jun 9, 2021

@mraible @amanganiello90 Thank you a lot for that! It will be a while until I can provide a fully working version of this, but I will keep you updated with my work here. So far I have managed to set up the NestJS GraphQL module during app generation, create a GraphQL resolver for the user entity and generate a GraphQL resolver when a new entity is created via the entity generator. I have also taken some basic steps on the frontend side with Angular, but there is still plenty to do on that end.

I am also considering to move the code to its own module (instead of integrating it into this blueprint). The new module could be compatible with the Node.js backend in the first version and could be extended to be working with Spring in the backend (or any other technology - if someone decides to implement it) at some point in the future too. As I am planning to generate the frontend code for consuming the GraphQL API too, I think it would be best to have an own module because otherwise the frontend code (which could also be of use for JHipster flavours other than Node.js) would be locked away in this blueprint and could not be re-used anywhere else.

@ghost
Copy link

ghost commented Jun 10, 2021

It is possible to have the entity backend part (nodejs) in the blueprint, and the frontend (i.e. Angular) in a module?
Remember that already exists an official Graphql jhipster module: https://github.com/ANDERSON1808/graphq-jhipster-generator for java backend side.

@ghost ghost assigned glutengo and unassigned ghost Jun 10, 2021
@glutengo
Copy link
Contributor Author

My work for the GraphQL integration is continued as a JHipster module here:
https://github.com/glutengo/generator-jhipster-gql
For now, it supports Angular and React in the frontend. The backend part currently supports the NodeJS Blueprint only (backend part is omitted if the blueprint is not detected), but I think it would be possible to integrate the existing Graphql Module for Java Backends at a later stage.

It is still very much work in progress, I just wanted to give a quick update so that you know where the work is continued.

@glutengo glutengo removed their assignment Jul 21, 2021
@ghost
Copy link

ghost commented Jul 21, 2021

Thanks @glutengo!!

@glutengo
Copy link
Contributor Author

First early version is now available: https://www.npmjs.com/package/generator-jhipster-gql

@ghost
Copy link

ghost commented Sep 21, 2021

Good!!

@ghost
Copy link

ghost commented Oct 23, 2022

Hi @glutengo. You can get your bug bounty if the issue is completed. So I close the issue. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
$$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ Feature New feature good first issue Good for newcomers question Further information is requested $500 https://www.jhipster.tech/bug-bounties/
Projects
None yet
Development

No branches or pull requests

2 participants