-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
[Draft] Transition to graphql-modules v1 #1148
[Draft] Transition to graphql-modules v1 #1148
Conversation
|
@pradel unfortunately graphql-modules v1 doesn't play well with apollo-server: Urigo/graphql-modules#1725 The fix would be easy but it's passed more than 1 year since the PR has been created and still no signs of merging: apollographql/apollo-server#4167 |
For the moment I simply updated the graphql-server-typescript example to simply use graphql-modules itself. |
The latency issue is really bad... It's pretty hard to justify the upgrade for the users if the execution is 2X slower |
So there is no way to not use graphql-modules by just using the schema it provides like it was possible with v0? |
Not with Apollo server, but it's possible with other GraphQL servers. |
@darkbasic any update here? I saw that the guild released a new package https://the-guild.dev/blog/introducing-envelop could it be something that we could use here? |
AFAIK envelop is not fully supported on Apollo as well. I will have to think more about this, the problem is Apollo not supporting custom execute. |
Ok so no good solutions for now.. Wondering if it makes sense to finish/release the other graphql-modules v1 migration to unblock some users. |
You mean the other PR? It faces the same Apollo limitations. |
Yeah it does face the same apollo limitations but at the same time it's working, just performance is really bad (This should be in the accounts-js docs to warn users)... I know some people are blocked by graphql-modules v0 and really need the migration to v1. You can also use the v1 without apollo by using other graphql servers. |
Can you please tell me which PR do you refer to? As far as I remember they both weren't working as well. |
Ah okay then maybe I misunderstood something, I am talking about this one #1141 |
I also just saw that apollo released apollo server v3, don't know if it's fixed in this version. |
Nope, they just ignored my request: apollographql/apollo-server#5262 (comment) Feel free to ping them about it. |
A workaround would be using something like this: Urigo/graphql-modules#1724 (comment) |
Yeah definitely not perfect but at least it would work.. |
I will try to give it another shot next week to refresh my mind about the possible alternatives. |
@pradel it took more than I anticipated to find some spare time to give this another try, but today I've managed to find some and this is how it's going to look like with apollo-server and the new API: import { createApplication } from 'graphql-modules';
const server = new ApolloServer({
schema: createApplication({
modules: [
createAccountsCoreModule({ accountsServer }),
createAccountsPasswordModule({ accountsPassword }),
],
schemaBuilder: ({ typeDefs: accountsTypeDefs, resolvers: accountsResolvers }) =>
makeExecutableSchema({
typeDefs: mergeTypeDefs([typeDefs, ...accountsTypeDefs]),
resolvers: mergeResolvers([...accountsResolvers, resolvers]),
}),
}).createSchemaForApollo(),
context: ({ req, connection }) => {
return context({ req, connection }, { accountsServer });
},
});
server.listen(4000).then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
}); and this is with boosts: const accounts = await accountsBoost({
services: {
password: {
[...]
},
},
},
tokenSecret: 'secret',
schemaBuilder: ({ typeDefs: accountsTypeDefs, resolvers: accountsResolvers }) =>
makeExecutableSchema({
typeDefs: mergeTypeDefs([typeDefs, ...accountsTypeDefs]),
resolvers: mergeResolvers([...accountsResolvers, resolvers]),
}),
} as any);
accounts.listen({
port: 4000,
}); If this is ok I'll rebase my branch (or rewrite it from scratch since I also need to port the codebase to the latest graphql-tools). |
@darkbasic Looks great! |
I've finished re-porting from scratch latest master to GraphQL Modules V1 and I've also updated every single dep to latest because I was annoyed by the tons of warnings. |
Amazing work! Can't wait to merge the pr :D |
Sorry for taking that long, but I've rewrote the schema stitching example from scratch and I've found a bug in GraphQL Modules which I took quite some time to figure out. I've managed to fix it, but it will require a new GraphQL Modules release. I'll keep you posted. |
There are still a few things I need to test before I will open the new PR, but in the meantime if you want you can have a look at https://github.com/darkbasic/accounts/tree/v1 |
PR is ready (#1189), I'm closing this. |
This is just a draft and the API is subject to changes.
It's already working, but there are many changes I want to do.