Comments (17)
Also, would be great if you would hide all NPM packages into the Meteor package so no Npm install would be necessary.
Definitely DO NOT do this. The whole idea is that you can update the NPM package as necessary without waiting for the Meteor package maintainer to get around to updating their wrapper.
from apollo-server.
Where are you putting the async await functions? The npm package is pre-built before publishing to NPM, so it's not really a problem with this package.
BTW @lorensr was thinking of working on a Meteor integration package as well!
from apollo-server.
For example in following code it says: "Can't wait without fiber" on line with Meteor.user retrieval
graphQLServer.use('/graphql', apolloServer(async(req) => {
let user = null;
if (req.headers.authorization) {
const token = req.headers.authorization;
check(token, String);
const hashedToken = Accounts._hashLoginToken(token);
user = await Meteor.users.findOne({
"services.resume.loginTokens.hashedToken": hashedToken
});
}
return {
graphiql: true,
pretty: true,
schema,
resolvers,
context: {
// The current user will now be available on context.user in all resolvers
user,
}
};
}));
from apollo-server.
It works fine here: https://github.com/apollostack/meteor-starter-kit/blob/master/server/main.js
I guess you put this code into an NPM package, and it doesn't work anymore?
The async
fiber support relies on Meteor's Promise
polyfill, so you should make sure you aren't including any other promise polyfills in your NPM package.
from apollo-server.
The previous code works flawlessly in Meteor, but when built as Npm package it fails.
from apollo-server.
Ha! The Meteor polyfill will be the problem ... would you be able to point me out how can I use it with babel?
from apollo-server.
You could just not use async
/await
in your package btw - that would be the easiest choice. Also, I'd suggest using an Atmosphere package instead of NPM for the short term, until Meteor 1.5 makes it possible for NPM packages to take advantage of more Meteor features.
from apollo-server.
I'll try with atmosphere package. Good idea.
I cannot work without async/await as all update / insert queries fail complaining that they do not run in Meteor Fiber.
from apollo-server.
@tomitrescak Hi Tomas, here's the shell I made for the atmosphere package:
https://github.com/apollostack/meteor-integration
I'd be interested to hear your thoughts on the API:
apollographql/meteor-integration#2
And would be happy to work on PRs with you if you'd like to combine efforts 😄
from apollo-server.
@lorensr looks great! I'll give it a go. My effort is not going very well. Just created the meteor package but am still getting "Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment." error.
Wht I miss in the package is the possibility to incrementally add resolvers. In a complex application with 50+ queries it would be great to have a possibility to split queries and mutations by modules. That is one of the things I tried to implement, but am hitting the wall with async.
I tried to look at how you've done it, but looks like you currently have only a shell, no implementation.
So, when you start to implement "useMeteorAccounts" you probably will run into very same issue. There the error is "Cannot await when not in Fiber".
from apollo-server.
Also, would be great if you would hide all NPM packages into the Meteor package so no Npm install would be necessary.
My repo is here:
https://github.com/tomitrescak/apollo-redux-tools.git
from apollo-server.
Wht I miss in the package is the possibility to incrementally add resolvers.
You can use _.merge to combine as many resolver objects as you want.
from apollo-server.
@stubailo ... just bumped into Meteor recommendation to NOT do that ;)
from apollo-server.
What do you mean?
from apollo-server.
I confirmed what you just said. I was checking the Meteor recommendations for package authors.
from apollo-server.
The moment I moved all npm dependencies form package to root level the async problem disappeared, yet another one appeared as "context" is always null in my queries.
This is how I init the server:
const res = {
graphiql: true,
pretty: true,
schema,
resolvers,
context: {
// The current user will now be available on context.user in all resolvers
user,
}
};
I'm sure that user is filled in. Then in my mutation:
addComment(root: any, { postId, comment }: any, context: any) {
console.log("adding: " + context);
const id = Comments.insert({ postId: postId, text: comment, createdAt: new Date().getTime(), author: context.user._id });
return Posts.findOne(id);
}
The context is null. Do you have any idea why this could happen?
[EDIT] Nevermind ... all solved.
from apollo-server.
@lorensr I like the API, most of it is there. I'll try to do the PR tomorrow with what I've done. You'll see how much of it is trash.
from apollo-server.
Related Issues (20)
- support for fastify version 4 HOT 2
- Allow passing http2 server to ApolloServerPluginDrainHttpServer
- ApolloServerPluginUsageReporting reportTimer has incorrect type HOT 1
- Elasticache cluster - CROSSLOT Keys in request don't hash to the same slot HOT 4
- Unable to package/deploy with serverless using Node14 and apollo-serverless-core HOT 3
- ApolloServerPluginUsageReporting does not allow to pass http agent HOT 11
- Misconfigured `sendVariableValues` results in similar behavior as `{all: true}` HOT 3
- ApolloServerPluginUsageReporting does not allow to pass http agent HOT 2
- Apis that have their requests cached dont need to make unnecessary auth token fetches
- Document known mitigated security issue in `@koa/cors` for AS3 users HOT 1
- Update `@koa/cors` dependency for AS3 (or why we don't intend to) HOT 2
- Share and modify variables between Express and the GraphQL/Apollo server HOT 1
- Error: ApolloServer<BaseContext>' is not assignable to type 'ApolloServer<ExpressContext> HOT 3
- callback function for onSchemaLoadOrUpdate when upgrading from AS v3 to AS v4 HOT 3
- Allow plugins to throw meaningful GraphQL errors
- Getting started tutorial has typescript issues...
- Delay when subscription is closed on client side of the router when using callback
- Documentation and dynamic cache control feature of Apollo leverages incompatible GraphQl type interface. HOT 3
- Disabling introspection should also disable "Did you mean ...?" HOT 2
- Undefined 'code' TypeError within errorNormalize HOT 1
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 apollo-server.