git clone https://github.com/apollostack/meteor-integration.git
cd meteor-integration
npm install
npm run test
Used in an app: https://github.com/lorensr/test-meteor-apollo
๐ meteor add apollo
Home Page: http://dev.apollodata.com/core/meteor.html
git clone https://github.com/apollostack/meteor-integration.git
cd meteor-integration
npm install
npm run test
Used in an app: https://github.com/lorensr/test-meteor-apollo
Are there any TypeScript type definitions available for meteor-integration
to overcome the TypeScript TS2307:Cannot find module 'meteor/apollo'.
warning message? Any work-arounds? Thanks!
Is there a way to use Apollo Optics with this package, or would we need to integrate Apollo manually to apply OpticsAgent as middleware and set opticsContext?
I was planning on only using lru-cache
, but @stubailo reminded me with talk of observe
that we're in Meteorland, not just nodeland. Shouldn't we first check whether Meteor has the current user's login info? If the client has a DDP connection open to the same app server as the app server that the GraphQL request comes to (which should happen if you have sticky routing like Galaxy), the info should be in memory in the same node process, right? Is there a Meteor lookup table of connection/session id -> connection object
? In which case we could use the userId
on the connection
object. So the client would send two headers, one with Meteor.connection._lastSessionId
, and one with the login token. It would try to look up the session, and if fails, use the lru-cache
.
Just released meteor/[email protected]
, but I think there's a bug in it. When I pointed meteor-starter-kit
at meteor-integration
locally, it worked, but after releasing and pointing at the atmosphere version, I started getting the bad behavior. It continues even when I switch back to local.
git clone [email protected]:apollographql/meteor-starter-kit.git
git checkout 0.3.0-wip
npm install
meteor
It would be nice to see this package come to life soon, so that we can use it like this:
https://github.com/apollostack/docs/pull/106
https://atmospherejs.com/webpack/webpack
Using async/await
gives this error:
GraphQL error: regeneratorRuntime is not defined
Taken from #25 (comment)
Hi,
I'm currently trying to make PersistedQueryNetworkInterface
from https://github.com/apollographql/persistgraphql work with this package, but as mail-client.js
uses createNetworkInterface
from the apollo-client package, there is no clean way to use another networkInterface
.
Why not simply set by hand the NetworkInterface, without using meteorClientConfig
?
Well because meteorClientConfig
is very convenient as it adds a middleware to support Meteor User Account, and I don't want to simply copy/paste this middleware into my code.
Do you think such a feature could be useful ? Would you be interested in a PR that enable the user to use a custom NetworkInterface inside meteorClientConfig ?
see vuejs/apollo#18. Not sure if it's the apollo-client or vue package that does the request itself.
If it's easily adjustable in the meteor app itself, please guide me on how to do that.
reported by @davidboom95
Hi, it seems this code breaks the meteor context, it should pass context.userId and context.user, when I try to reverse changes, context is still undefined. I tried meteor reset, and re-install apollo-server but it does not work
For v1, only caching and providing user id as context, not whole user doc.
How many MB default cache size? 6.6k users per MB. 512 MB RAM in smallest Galaxy container.
Cache key is 44 characters. At 2B/character, that's 88B/key. The value is [id, expires]
. The attributes are:
88 + 34 + 8 + 20 = 150 B per entry.
Can someone give a snippet example of how to store the graphql queries externally or separately in a file (.graphql or whatever extension)? And from which directory to import them into the meteor app?
Following the instructions here, I added the Apollo packages to my Meteor (1.4.3.1) app with these commands:
meteor add apollo
meteor npm install --save apollo-client graphql-server-express express graphql graphql-tools body-parser
However, this resulted in an invalid combination of versions:
WARNING: npm peer requirements (for apollo) not installed:
- apollo-server@^0.1.1 not installed.
- http-proxy-middleware@^0.15.0 not installed.
This is caused by the fact that for some reason, I got Apollo v0.0.1, which depends on a completely different set of NPM packages, not the one I installed (following the instructions).
Since according to the relevant Atmosphere page, the latest version of the Apollo Meteor package is 0.3.1, I updated it manually:
meteor add [email protected]
With this, it got closer to working, but still not there. Now I get these messages:
WARNING: npm peer requirements (for apollo) not installed:
- [email protected] installed, graphql-server-express@^0.5.0 needed
- [email protected] installed, graphql@^0.7.0 || ^0.8.0 needed
- [email protected] installed, graphql-tools@^0.9.0 needed
So, now the peer dependencies are there, but it looks like the Meteor package is lagging behind the NPM versions. Is there a chance that it will be updated soon?
In the meantime, can I ignore these warnings, and just use the package anyway?
(I am new to Apollo, so I would like to avoid having to figure out whether any problems I hit originate in version incompatibilities...)
Thanks.
I get this error when adding graphql to my Meteor server code:
/.../...app/.meteor/local/build/programs/server/packages/modules.js:55907
W20160929-19:06:56.052(3)? (STDERR) const graphql_1 = require('graphql');
W20160929-19:06:56.053(3)? (STDERR) ^^^^^
W20160929-19:06:56.054(3)? (STDERR) SyntaxError: Use of const in strict mode.
This is what I used to install Apollo:
meteor add apollo
meteor npm install --save apollo-client apollo-server express graphql graphql-tools body-parser
This is the code I've added:
import { createApolloServer } from 'meteor/apollo';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
const typeDefs = [`
type Email {
address: String
verified: Boolean
}
type User {
emails: [Email]
username: String
randomString: String
}
type Query {
user(id: String!): User
}
schema {
query: Query
}
`];
const resolvers = {
Query: {
async user(root, args, context) {
// Only return the current user, for security
if (context.userId === args.id) {
return await Meteor.users.findOne(context.userId);
}
},
},
User: {
emails: ({emails}) => emails,
randomString: () => Meteor.Random.id(),
}
}
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
createApolloServer({
schema,
});
I'm on Meteor 1.3.3.1.
Top of main-client.js
is import '/check-npm.js';
. This works on the server, but doesn't appear to work on the client โ when I run this app to test:
https://github.com/lorensr/meteor-starter-kit/tree/apollo-package
I get this error on client:
(note if you run the app, you need to fix the packages/apollo
symlink)
Hi
How do i add CORS to the apollo instance ?
I'v been working in test-apps and now i want to move my Apollo-Express to Meteor/Apollo. Im trying to obtain the "app" or "graphqlServer" instance to call the .use() method. Maybe is it ready ? or im confused...
Thanks
Currently 4000. From @timbrandin:
Should we set the default port to 80 and just note to not put an asset or route at /graphql
?
We should at least support passing 80 as a config param.
My app is written in Blaze and I don't want to use Apollo client right now. I am interested in connecting from a React Native app to Apollo on my Meteor server however.
I removed apollo-client
as an npm package from my Meteor app and I now get the following error warning in the browser console:
check-npm-versions.js:53 WARNING: npm peer requirements (for apollo) not installed:
- apollo-client@^0.4.0 || ^0.3.0 not installed.
Read more about installing npm peer dependencies:
http://guide.meteor.com/using-packages.html#peer-npm-dependencies
checkNpmVersions @ check-npm-versions.js:53
modules-runtime.js?hash=ab7e8d3โฆ:470 Uncaught Error: Cannot find module 'apollo-client'(โฆ)
I don't if this has any major effects, but it would be nice to be able to use Apollo with Meteor server side only.
I'm having this issues when following the Header example from: http://dev.apollodata.com/react/auth.html.
I don't seem to have the same options for accessing the Req in the context in createApolloServer?
When is the ETA in publishing this to (Atmosphere) Meteor?
Looks quite solid to me already.
Hi, would be nice if the gal tag was also automatically registered. Thanks!
Let's say we've got the following very simple GraphQL schema:
type ContentBlock {
_id: String
content: String
}
type RootQuery {
contentBlock(id: String!): ContentBlock
}
type RootMutation {
upsertContentBlock(id: String!, content: String!): ContentBlock
}
schema {
query: RootQuery
mutation: RootMutation
}
At first let's connect
our React component with:
function mapQueriesToProps({ownProps: {contentId}}) {
return {
data: {
query: gql`
query getContent ($id: String!) {
contentBlock(id: $id) {
_id
content
}
}
`,
variables: {id: contentId}
}
}
}
Resolvers:
{
RootQuery: {
contentBlock(root, args, context) {
try {
return context.connectors.ContentBlock.findById(args.id);
} catch (err) {
console.log(err.stack);
throw err;
}
},
},
RootMutation: {
upsertContentBlock(root, args, context) {
try {
return context.connectors.ContentBlock.upsert(args.id, args.content);
} catch (err) {
console.log(err.stack);
throw err;
}
},
},
};
ContentBlock
connector:
class ContentBlockConnector {
findById(id) {
return ContentBlocks.findOne(id);
}
upsert(id, content) {
const result = ContentBlocks.upsert({_id: id}, {
$set: {content}
});
return ContentBlocks.findOne(id);
}
}
Note: ContentBlocks
is a Mongo.Collection
.
So far everything works fine. The connect
ed React component successfully fetches content by contentId
. Now let's try to add the mutation and connect
our component with:
function mapMutationsToProps({ownProps: {contentId}}) {
return {
saveContent: (content) => {
return {
mutation: gql`
mutation updateContent($id: String!, $content: String!) {
upsertContentBlock(id: $id, content: $content) {
_id
content
}
}
`,
variables: {
id: contentId,
content,
},
};
},
};
}
Now when we call this.props.mutations.saveContent(content);
within our react component, we get the following Error on the server: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
Now let's change our mutation resolver to do the exact same thing the query resolver does:
{
RootQuery: {
contentBlock(root, args, context) {
try {
return context.connectors.ContentBlock.findById(args.id);
} catch (err) {
console.log(err.stack);
throw err;
}
},
},
RootMutation: {
upsertContentBlock(root, args, context) {
try {
return context.connectors.ContentBlock.findById(args.id);
} catch (err) {
console.log(err.stack);
throw err;
}
},
},
};
Calling this.props.mutations.saveContent(content);
now still yields an Error: Can't wait without a fiber
.
Now try to use Meteor.bindEnvironment
to wrap the resolver (note that the Meteor package already does WebApp.connectHandlers.use(Meteor.bindEnvironment(graphQLServer));
) :
{
...
RootMutation: {
upsertContentBlock: Meteor.bindEnvironment(function (root, args, context) {
...
}),
},
}
No more error, but inspecting the GraphQLResult
from this.props.mutations.saveContent(content).then(GraphQLResult => ...)
shows that its data
property is {upsertContentBlock: null, __typename: "RootMutation"}
where upsertContentBlock
shouldn't be null
because the resolver returns an object.
Is anyone experiencing the same problems when using Apollo with Meteor? Can someone explain what's going on there and why calling methods on Mongo.Collection
s work with query resolvers and don't work (as expected) with mutation resolvers?
Thanks in advance.
{
"apollo-client": "^0.3.24",
"apollo-server": "^0.1.5",
"react": "^15.1.0",
"react-apollo": "^0.3.13",
}
Cross-posted from https://github.com/apollostack/docs/issues/23
I currently have a currentUser
query in my global app container that loads the current user, and I'm handling user accounts through the accounts-ui package.
The problem is that the Apollo query doesn't know it needs to re-run when the Meteor user's logged in/logged out state changes.
So the flow looks something like this:
currentUser
which returns nothing because no user is logged in.currentUser
to get the current user profile.As you can see things break down at step 3. What's the best way of telling the query to rerun? One solution would be calling refetch()
in an autorun block containing Meteor.user()
?
Another issue related to the way I've currently set things up is that refetching the currentUser
query would force my entire app to reload:
const AppContainer = (props, context) => {
const {loading, refetch, currentUser, categories} = props.data;
return <Telescope.components.App
ready={!loading}
currentUser={currentUser}
categories={categories}
events={Events}
{...props}
/>;
};
Is there a way to rerun the query without setting loading
to false
? Or a better pattern for setting up your app container?
Hey,
One question thats bothering me: Is it possible to completely remove mongo and minimongo from the client?
This package uses accounts-base
which has a dependency to mongo
, so I guess thats the problem here right?
So I've been using a form of account impersonation for my admin team to manage other people's accounts and/or data without knowing their passwords, etc.
Loosely based on https://dweldon.silvrback.com/impersonating-a-user I use, @gwendall's https://github.com/gwendall/meteor-impersonate
Would it be possible to somehow integrate these two packages, so that the impersonation isn't "lost" in the Apollo data endpoints.
Perhaps @lorensr will have some words of wisdom!? ๐
WARNING: npm peer requirements (for apollo) not installed:
- [email protected] installed, apollo-client@^0.3.12 needed
๐
the latest apollo version 0.1.2 seems to be broken, localhost:3000/graphiql fails with:
TypeError: undefined is not an object (evaluating 't.toString')
both with Meteor 1.4.1.1 and 1.4.1.2
version 0.1.1 runs fine.
We have docs, we have starter kit, but I feel like many folks in the Meteor world still seem to have troubles to grasp how it works together.
I'm not that much on the forums, but I've seen that in my local meetup (Paris, FR) & listening to Transmission Podcast.
I've created a code tour to demystify that:
Here is how to have a look at it directly: https://www.codetours.xyz/tour/xavcz/meteor-apollo-codetour
I would love your feedback on it to make it clearer how to spread the word that building something with Meteor & Apollo is not obscure at all!
โก๏ธ Codetour: https://www.codetours.xyz/tour/xavcz/meteor-apollo-codetour
โก๏ธ Repo to correct my fragile English syntax and enhance the Markdown formatting: https://github.com/xavcz/meteor-apollo-codetour ๐
I'm building a isomorphic app that does server side rendering, wen I try to use the apollo client on the server side like:
import ApolloClient from 'apollo-client';
import {meteorClientConfig} from 'meteor/apollo';
const client = new ApolloClient(meteorClientConfig());
It fails, server command line log shows that meteorClientConfig is not a function.
Wen I put a condition
var client = {};
if(Meteor.isClient){
client = new ApolloClient(meteorClientConfig());
console.log(client);
}
It works but that means the server cant access the db, only the browser.
ps: originally posted here apollographql/apollo-client#1006
With the new apollo-client
update, we have to add queryTransformer
and dataIdFromObject
when initializing ApolloClient and I feel like there are lots changes happening. I think it would be better if these APIs don't surface to the user. I created my own meteor-apollo integration for testing. Check it out here.
In my repo, user will just do
const client = configureGraphQLClient();
and an ApolloClient is created.
Getting this error when running from master
Error: Can't find npm module 'meteor/tmeasday:check-npm-versions/check-npm-versions.js'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
There is a version of graphiql that supports HTTP headers, in which case we could use the auth header that the meteor app uses:
Or maybe we could put the auth token in a query variable?
Thanks @rdickert for the good idea
root schema and resolver:
const rootSchema = `
type RootQuery {
user: User
...
allFeedbacks: [Feedback]
}
schema {
query: RootQuery
}
`
RootQuery: {
...
async allFeedbacks(root, args, context) {
const allFeedbacks = DB.Feedback.find({patientId: {$exists: 1}}).fetch()
return await allFeedbacks
},
...
}
feedback.js
export const schema = `
type Feedback {
_id: String
patient: User
opinion: String
reply: String
}
`;
export const resolvers = {
Feedback: {
_id : ({_id}) => _id,
patient: async ({patientId}) => {
return await Meteor.users.findOne({_id:patientId})
},
opinion: ({opinion}) => opinion,
reply: ({reply}) => reply,
}
};
query in graphiql:
{ allFeedbacks { patient { username } _id opinion reply } }
Got result:
{
"data": {
"allFeedbacks": [
{
"patient": null,
"_id": "nyNP9wh9D5qmZixbn",
"opinion": "tesst",
"reply": "testst"
},
{
"patient": null,
"_id": "WgSoCgTGhHeZasFGQ",
"opinion": "tesst",
"reply": "testst"
},
...
{
"message": "Can't wait without a fiber",
"locations": [
{
"line": 4,
"column": 5
}
]
},
}
It's strange when i test , the resolver could console log PatientId, Meteor, Meteor.users, But can't get the fetched data. I guess the problem is on async, but where is the problem?
Had checked sample repos, followed their pattern but no luck.
Call this function in parallel with looking up the user (in the case that we're going to do both):
https://github.com/apollostack/meteor-integration/blob/master/main-server.js#L26
Because we don't know how long the provided function will take to complete.
Instead of just caching the userId. Configurable cache duration, ability to go through or invalidate.
waiting on Meteor-Community-Packages/check-npm-versions#7 to fix
Meteor supplies us with a great websocket implementation with authentication, retries and more. We could simply leverage this power by making a network interface that calls a DDP method:
// ddp-network-interface.js
class DDPNetworkInterface {
constructor({
connection,
noRetry = true,
method = '/graphql' } = {}
) {
this.connection = connection;
this.noRetry = noRetry;
this.method = method;
}
query(request) {
return new Promise((resolve, reject) => {
this.connection.apply(this.method, [request], { noRetry: this.noRetry }, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
}
export { DDPNetworkInterface };
// client.js
import ApolloClient from 'apollo-client';
import { DDPNetworkInterface } from './ddp-network-interface';
export const client = new ApolloClient ({
networkInterface: new DDPNetworkInterface({ connection: Meteor.connection })
})
import { schema } from './schema';
import { runQuery } from 'apollo-server';
export const methods = {
'/graphql'({ query, variables }) {
this.unblock();
const { userId } = this;
return runQuery({
schema,
query,
variables,
context: {
userId
}
}).await();
}
};
Meteor.methods(methods);
I'm testing this for our own app and it's seems to work perfectly so far.
If people are interested in this I would love to make a PR for it. What do you think @lorensr?
Do we need apollo-server
on our package.json
file anymore (since updated to [email protected]
)?
I mean, you are no longer using apollo-server
, instead you are using graphql-server-express
. Is there a special reason for the decission?
First of all: thanks for providing this integration for Meteor.
When using the latest meteor-integration from Atmosphere I get the warning: [email protected] installed, apollo-client@^0.5.0 needed
. Can that be safely ignored?
If not, am I constrained to v0.5.0
of apollo-client with Meteor (at least when I want to use this integration)? When will there be an update that supports the latest versions?
Thank you so much for your efforts!
Update (Just for the sake of completeness)
I get the following warnings on the server side:
WARNING: npm peer requirements (for apollo) not installed:
[email protected] installed, graphql-server-express@^0.4.3 needed
[email protected] installed, graphql@^0.7.0 || ^0.8.0 needed
[email protected] installed, graphql-tools@^0.8.0 needed
Hi, this no longer works with Apollo server 2.0+
I managed to solve most of the issues, but I have no idea how to approach the filling of context with meteor users information, since server 2.0 now uses context as a simple object.
I have this code for my mutation. Everything is working perfectly everywhere but in IE11. It throws an error because there in no context.
Mutation: {
insertBusinessIdea (_, {name}, context) {
if (!context.userId) {
throw new Meteor.Error('User must be logged in to create a new Business Idea') //IE11 not working
}
const businessIdeaId = BusinessIdeas.insert({
name: name,
createdBy: context.userId,
createdAt: new Date()
})
return BusinessIdeas.findOne(businessIdeaId)
}
This would go in a different package. If you're interested and would like some guidance, talk to Sashko!
When calling Meteor.logout(), the context.userId on the server side should be set to undefined. Instead, it is still set as the id for the previously logged in user. If I restart the server process, the cached userId is cleared and all is well again.
described in readme: https://github.com/apollostack/meteor-integration
Maybe this?
if (Meteor.isDevelopment)
serverOptions.debug = true
http://dev.apollodata.com/tools/graphql-server/setup.html#graphqlOptions
I'm getting WARNING: npm peer requirements (for apollo) not installed: [email protected] installed, graphql@^0.6.2 needed
. Everything seems to work fine, so that dependency should probably be updated to add 0.7.x.
Also there is a dependency on 'apollo-client': '^0.4.11'
, but it seems to work fine with client 0.3.x. I haven't tested extensively, but I don't see anything that touches API changes for 0.4.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.