Skip to content

Use GraphQLModules#493

Merged
TimMikeladze merged 5 commits intoaccounts-js:masterfrom
ardatan:Use-GraphQLModules
Nov 15, 2018
Merged

Use GraphQLModules#493
TimMikeladze merged 5 commits intoaccounts-js:masterfrom
ardatan:Use-GraphQLModules

Conversation

@ardatan
Copy link
Copy Markdown
Contributor

@ardatan ardatan commented Nov 6, 2018

  • Use GraphQL-Modules instead of a factory function and add AccountsModule to support and also it exposes typeDefs, schema, resolvers for non-GraphQL-Modules project.
  • Update documentation related to these changes

@ardatan ardatan force-pushed the Use-GraphQLModules branch 2 times, most recently from 4c1aa41 to 74a13bb Compare November 6, 2018 11:26
@pradel
Copy link
Copy Markdown
Member

pradel commented Nov 6, 2018

Hey, thanks for the pr, can you give a bit of context for these changes please?

@ardatan ardatan force-pushed the Use-GraphQLModules branch 3 times, most recently from 4eb1e5e to 2054e21 Compare November 7, 2018 07:28
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 7, 2018

Codecov Report

Merging #493 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #493   +/-   ##
=======================================
  Coverage   95.77%   95.77%           
=======================================
  Files          57       57           
  Lines        1277     1277           
  Branches      179      179           
=======================================
  Hits         1223     1223           
  Misses         51       51           
  Partials        3        3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c80f587...a9162a6. Read the comment docs.

@ardatan ardatan force-pushed the Use-GraphQLModules branch 4 times, most recently from d6af22b to b549fc5 Compare November 9, 2018 23:32
@ardatan
Copy link
Copy Markdown
Contributor Author

ardatan commented Nov 9, 2018

Hi @pradel,
Sorry for late response.
We just released GraphQL-Modules which provides you to implement your GraphQL applications or libraries in modular approach together with features like Depenedency Injection, Resolvers Composition etc.
I am one of the contributors of that project.
You can read more in this article and its website;
https://medium.com/the-guild/graphql-modules-feature-based-graphql-modules-at-scale-2d7b2b0da6da
https://graphql-modules.com

We would love to see AccountsJS has built-in GraphQL-Modules support, and uses the benefits of our library. @dotansimha is one of the main contributors of GraphQL-Modules, and AFAIK he also contributed to graphql-api package of yours.

We also want to write a blog post about a GraphQL boilerplate with Authentication using GraphQL-Modules and AccountsJS together with GraphQL Code Generator's TypeScript benefits that will be so much easy to start a GraphQL project with Authentication for beginners.

To sum up, the benefits are;

  • You don't need to think about the support of GraphQL libraries and the other stuff. This is what GraphQL-Modules will take care of for you.
  • GraphQL-Modules has built-in support for Apollo Server and graphql-yoga even if they're not using GraphQL-Modules.
  • GraphQL-Modules also supports GraphQL Code Generator out of the box which generates client-side and server-side typings including resolvers signatures, and strictly-typed React-Apollo and Apollo Angular components and services. That will be also included in your graphql-api package if you start to use GraphQL-Modules with this PR.
  • https://medium.com/the-guild/graphql-code-generator-v0-11-15bb9b02899e

@ardatan ardatan force-pushed the Use-GraphQLModules branch 2 times, most recently from ae7120a to 5897851 Compare November 9, 2018 23:38
@dotansimha
Copy link
Copy Markdown
Member

I think it's great :)
It's exposing a clean GraphQLModule which you can use with graphql-modules, but the module is also independent, so you can get typeDey/resolvers/GraphQLSchema as standalone and use it without graphql-modules.

@davidyaha what do you think? 😄

@TimMikeladze
Copy link
Copy Markdown
Member

I think this is a great idea, will review soon, thanks for the contribution!

Signed-off-by: Arda TANRIKULU <[email protected]>
Comment thread packages/graphql-api/src/modules/accounts-password/index.ts Outdated
@pradel
Copy link
Copy Markdown
Member

pradel commented Nov 13, 2018

I like the idea too!
Will take a deeper look when I have some time :)

Comment thread packages/graphql-api/README.md Outdated
@pradel
Copy link
Copy Markdown
Member

pradel commented Nov 14, 2018

Code looks good and e2e tests are passing!
I just have one question since I am not familiar with graphql-modules.
How can a user extends the User type to add additional fields?
For example right now you can do it like this:

const typeDefs = `
  extends type User {
	firstname: String!
  }
`;

Then this field will be injected by the account module user resolver directly

@pradel
Copy link
Copy Markdown
Member

pradel commented Nov 14, 2018

Same when we are creating a new user, how to extends the createUser input with new variables?

@ardatan
Copy link
Copy Markdown
Contributor Author

ardatan commented Nov 14, 2018

Everything is same if you're not using GraphQL-Modules, I mean the exported schema is exactly same like before; so you can still use extend for extending inputs and other types. But for GraphQL-Modules users, there is no need to add extend operator, because GraphQL-Modules handles that for you :) The only thing you need to do is to import AccountsModule to your application module which contains extra fields etc.

import { AccountsModule } from '@accounts/graphql-api';
import { GraphQLModule } from '@graphql-modules/core';

export const AppModule = new GraphQLModule({
  typeDefs: gql`
    type User {
	firstname: String!
  }
    input CreateUserInput {
         firstName: String!
    }
  `,
  resolvers: {...},
  imports: [
   AccountsModule.forRoot({...})
  ]
});

const { typeDefs } = AppModule;
// Now typeDefs has User and CreateUserInput types with firstname and other fields from AccountsModule

@pradel
Copy link
Copy Markdown
Member

pradel commented Nov 14, 2018

Amazing thanks for the explanation @ardatan!
We will have to reflect that in the documentation :)

@ardatan
Copy link
Copy Markdown
Contributor Author

ardatan commented Nov 14, 2018

@pradel Thank you for your good thoughts :) It is really great to see these two projects together.

@davidyaha
Copy link
Copy Markdown
Member

@dotansimha Graphql Modules sounds great! Congrats on open sourcing it!!
Hadn't tried it myself yet but it looks like a very good approach and could be very much inline with accounts-js IMO.
Unfortunately I don't have the time to review but it seems like @pradel and @TimMikeladze are on it.
Thanks for the contribution @ardatan!

Copy link
Copy Markdown
Member

@TimMikeladze TimMikeladze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@dotansimha
Copy link
Copy Markdown
Member

@pradel @TimMikeladze @davidyaha Any chance we can get it merged and released soon? 😄
Thanks!

@TimMikeladze
Copy link
Copy Markdown
Member

I can merge and cut a release within the next 24 hours.

@TimMikeladze TimMikeladze merged commit 36c6d64 into accounts-js:master Nov 15, 2018
@TimMikeladze
Copy link
Copy Markdown
Member

Thanks for the PR 👍

Merged and published. 0.5.0-alpha.1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants