GithubHelp home page GithubHelp logo

swydo / ddp-apollo Goto Github PK

View Code? Open in Web Editor NEW
177.0 11.0 15.0 317 KB

DDP link for Apollo with GraphQL Subscriptions support

License: MIT License

JavaScript 100.00%
apollo meteor grapql ddp apollo-client graphql-subscriptions apollo-link

ddp-apollo's Introduction

DDP-Apollo

DDP-Apollo leverages the power of DDP for GraphQL queries and subscriptions. Meteor developers do not need an HTTP server or extra websocket connection, because DDP offers all we need and has been well tested over time.

Github Header

  • DDP-Apollo is one of the easiest ways to get GraphQL running for Meteor developers
  • Works with the Meteor accounts packages out of the box, giving a userId in your resolvers
  • Method calls and collection hooks will have this.userId when called within your resolvers
  • Doesn’t require an HTTP server to be setup, like with express, koa or hapi
  • Supports GraphQL Subscriptions out-of-the-box
  • Doesn’t require an extra websocket for GraphQL Subscriptions, because DDP already has a websocket
  • Already have a server setup? Use DDPSubscriptionLink stand-alone for just Subscriptions support. Read more

Just another Apollo Link

Because it's "just another Apollo Link":

  • It works with Apollo Dev Tools
  • It's easy to combine with other Apollo Links
  • It's front-end agnostic

Starter Kit

Checkout this starter kit to see Meteor, Apollo, DDP and React all work together.

Note: DDP-Apollo works with all front-ends, not just React

Build Status

Contents

Installation

meteor add swydo:ddp-apollo
meteor npm install --save @apollo/client @swydo/apollo-link-ddp graphql

Client setup

All client code is in the @swydo/apollo-link-ddp npm package. It gives you a DDPLink for your Apollo Client. Creating an Apollo Client is the same as with any other Apollo Link.

// Choose any cache implementation, but we'll use InMemoryCache as an example
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { DDPLink } from '@swydo/apollo-link-ddp';

export const client = new ApolloClient ({
  link: new DDPLink(),
  cache: new InMemoryCache()
});

Options

  • connection: The DDP connection to use. Default Meteor.connection.
  • method: The name of the method. Default __graphql.
  • publication: The name of the publication. Default __graphql-subscriptions.
  • ddpRetry: Retry failed DDP method calls. Default true. Switch off and use apollo-link-retry for more control.
  • socket: Optionally pass a socket to listen to for messages. This makes it easy to integrate with non-Meteor DDP clients.
// Pass options to the DDPLink constructor
new DDPLink({
  connection: Meteor.connection
});

Server setup

The server will add a method and publication that will be used by the DDP Apollo Link.

import { schema } from './path/to/your/executable/schema';
import { setup } from 'meteor/swydo:ddp-apollo';

setup({
  schema,
  ...otherOptions
});

Options

  • schema: The GraphQL schema. Default undefined. Required when no gateway is provided.
  • gateway: An Apollo Gateway. Default undefined. Required when no schema is provided.
  • context: A custom context. Either an object or a function returning an object. Optional.
  • method: The name of the method. Default __graphql.
  • publication: The name of the publication. Default __graphql-subscriptions.

Custom context

To modify or overrule the default context, you can pass a context object or function to the setup:

// As an object:
const context = {
  foo: 'bar'
}

// As a function, returning an object:
const context = (currentContext) => ({ ...currentContext, foo: 'bar' });

// As an async function, returning a promise with an object
const context = async (currentContext) => ({ ...currentContext, foo: await doAsyncStuff() });

setup({
  schema,
  context,
});

GraphQL subscriptions

Subscription support is baked into this package. Simply add the subscriptions to your schema and resolvers and everything works.

Note: Apollo Gateway does not yet support Subscriptions.

# schema.graphql
type Query {
  name: String
}

type Subscription {
  message: String
}

Setting up PubSub

meteor npm install --save graphql-subscriptions
import { PubSub } from 'graphql-subscriptions';

// The pubsub mechanism of your choice, for instance:
// - PubSub from graphql-subscriptions (in-memory, so not recommended for production)
// - RedisPubSub from graphql-redis-subscriptions
// - MQTTPubSub from graphql-mqtt-subscriptions
const pubsub = new PubSub();

export const resolvers = {
  Query: {
    name: () => 'bar',
  },
  Subscription: {
    message: {
      subscribe: () => pubsub.asyncIterator('SOMETHING_CHANGED'),
    },
  },
};

// Later you can publish updates like this:
pubsub.publish('SOMETHING_CHANGED', { message: 'hello world' });

See graphql-subscriptions package for more setup details and other pubsub mechanisms. It also explains why the default PubSub isn't meant for production.

Using DDP only for subscriptions

If you already have an HTTP server setup and you are looking to support GraphQL Subscriptions in your Meteor application, you can use the DDPSubscriptionLink stand-alone.

import { ApolloClient, InMemoryCache, HttpLink, split } from '@apollo/client';
import { DDPSubscriptionLink, isSubscription } from '@swydo/apollo-link-ddp';

const httpLink = new HttpLink({ uri: "/graphql" });
const subscriptionLink = new DDPSubscriptionLink();

const link = split(
  isSubscription,
  subscriptionLink,
  httpLink,
);

export const client = new ApolloClient ({
  link,
  cache: new InMemoryCache()
});

Rate limiting GraphQL calls

Meteor supports rate limiting for DDP calls. This means you can rate limit DDP-Apollo as well!

meteor add ddp-rate-limiter
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';

// Define a rule that matches graphql method calls.
const graphQLMethodCalls = {
  type: 'method',
  name: '__graphql'
};

// Add the rule, allowing up to 5 messages every 1000 milliseconds.
DDPRateLimiter.addRule(graphQLMethodCalls, 5, 1000);

See DDP Rate Limit documentation.

HTTP support

There can be reasons to use HTTP instead of a Meteor method. There is support for it built in, but it requires a little different setup than the DDP version.

Installation

We'll need the HTTP link from Apollo and body-parser on top of the default dependencies:

meteor npm install @apollo/client body-parser

Client setup

import { ApolloClient, InMemoryCache } from '@apollo/client';
// Use the MeteorLink instead of the DDPLink
// It uses HTTP for queries and Meteor subscriptions (DDP) for GraphQL subscriptions
import { MeteorLink } from '@swydo/apollo-link-ddp';

export const client = new ApolloClient ({
  link: new MeteorLink(),
  cache: new InMemoryCache()
});

Server setup

import { schema } from './path/to/your/executable/schema';
import { setupHttpEndpoint, createGraphQLPublication } from 'meteor/swydo:ddp-apollo';

setupHttpEndpoint({
  schema,
  ...otherOptions,
});

// For subscription support (not required)
createGraphQLPublication({ schema });

Options

  • schema: The GraphQL schema. Default undefined. Required when no gateway is provided.
  • gateway: An Apollo Gateway. Default undefined. Required when no schema is provided.
  • context: A custom context. Either an object or a function returning an object. Optional.
  • path: The name of the HTTP path. Default /graphql.
  • engine: An Engine instance, in case you want monitoring on your HTTP endpoint. Optional.
  • authMiddleware: Middleware to get a userId and set it on the request. Default meteorAuthMiddleware, using a login token.
  • jsonParser: Custom JSON parser. Loads body-parser from your node_modules by default and uses .json().

Sponsor

Want to work with Meteor and GraphQL? Join the team!

ddp-apollo's People

Contributors

boomfly avatar cliffzz avatar csillag avatar dependabot-preview[bot] avatar greenkeeper[bot] avatar jamiter avatar moberegger avatar zvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ddp-apollo's Issues

An in-range update of eslint is breaking the build 🚨

Version 4.18.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.17.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 14 commits.

  • 883a2a2 4.18.0
  • 89d55ca Build: changelog update for 4.18.0
  • 70f22f3 Chore: Apply memoization to config creation within glob utils (#9944)
  • 0e4ae22 Update: fix indent bug with binary operators/ignoredNodes (fixes #9882) (#9951)
  • 47ac478 Update: add named imports and exports for object-curly-newline (#9876)
  • e8efdd0 Fix: support Rest/Spread Properties (fixes #9885) (#9943)
  • f012b8c Fix: support Async iteration (fixes #9891) (#9957)
  • 74fa253 Docs: Clarify no-mixed-operators options (fixes #9962) (#9964)
  • 426868f Docs: clean up key-spacing docs (fixes #9900) (#9963)
  • 4a6f22e Update: support eslint-disable-* block comments (fixes #8781) (#9745)
  • 777283b Docs: Propose fix typo for function (#9965)
  • bf3d494 Docs: Fix typo in max-len ignorePattern example. (#9956)
  • d64fbb4 Docs: fix typo in prefer-destructuring.md example (#9930)
  • f8d343f Chore: Fix default issue template (#9946)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of apollo-client is breaking the build 🚨

Version 2.0.3 of apollo-client was just published.

Branch Build failing 🚨
Dependency apollo-client
Current Version 2.0.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

apollo-client is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Apollo-Client 2.1.0?

"apollo-client": "2.1.0"

I did not know that apollo-client 2.1 was out? The NPM page only lists v2.0.4.

import { ApolloClient, split } from 'apollo-client'

split is completely undocumented in Apollo, is this meant to make it easier to concat middleware? (if so this would make my life so much easier!)

Disappearing messages?

We are facing a mysterious issue with ddp-apollo.

In some circumstances (which are really peculiar, and hard to reproduce), some of the messages that we try to send over the DDP-Apollo link from the server to the client seem to be lost.

Here are the details:

  • We are routing all our GraphQL traffic between the client and the server via the already existing DDP web socket. (No HTTP requests.) This includes GraphQL queries, mutations and subscriptions.
  • The queries always work correctly.
  • Sometimes, some of the subscription events don't make it to the client.
  • We have added logging messages on both sides like crazy, and also using Chrome's WebSocket traffic analyzer to check the traffic. Based on this, we are 100% sure that the web socket is "live" (ie. Meteor's socket keep-alive ping-pong is happening normally), but also 100% sure that the subscription notifications are not arriving to the client
  • Based on our server logs, we are also 99% sure that the server does publish the events towards the client. (Except is there is a hidden exception somewhere, after we print out the relevant log message, but before we actually send the event.... unlikely, but not absolutely impossible)

Currently we are at loss about how to debug this any more.
My questions are:

  • Has anything like this ever been encountered by anyone else?
  • Is there a way to enable more logging in the ddp-apollo layer, both client- and server-side, especially about the pub/sub events? In order to isolate the issue better, we would need to see if the server-side code of DDP-Apollo really sees and forwards the message to the DDP socket.

Thank you for your help.

Is apollo-link-http required?

As apollo-link-ddp is using apollo-link-http I think the installation instruction is missing it in the install command.

I just updated my app from 1.3 to 2.x and I was getting this error:

Unable to resolve some modules:

  "apollo-link-http" in
/Users/filipenevola/Documents/quave/ws/bemarke/node_modules/apollo-link-ddp/dist/client/apollo-link-meteor.js

Can I submit a PR updating the README or I didn't get something?

Thanks

"Cannot read property 'request'" error on client.query?

I recently discovered Swydo:ddp-apollo and am excited to be integrating it into my project.

Before moving to Swydo:ddp-apollo, I could do this:

            this.client.query({
                query: MY_QUERY,
                variables: {userID: userID},
            }).then((result) => {
                _this.myData = result.data.getMyData[0];
            });

Now, upgrading from Apollo 1.5 to Apollo 2.0, and using Swydo:ddp-apollo, this is throwing an error:

Uncaught TypeError: Cannot read property 'request' of undefined

Here's the stack trace:

modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86635 Uncaught TypeError: Cannot read property 'request' of undefined
    at isTerminating (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86635)
    at concat (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86736)
    at DedupLink.ApolloLink.concat (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86759)
    at modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86708
    at Array.reduce (<anonymous>)
    at Function.from (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:86708)
    at new QueryManager (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:84615)
    at ApolloClient.initQueryManager (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:85587)
    at ApolloClient.query (modules.js?hash=2320715bcd54b0c39feeb19622066e59abc141d7:85545)
    at Layout.getUserInfoForCurrentUser (main_layout.jsx:298)

Is this something relating to Swydo:ddp-apollo, or relating to Apollo 2.0?

Thanks in advance for the info.

`TypeError: SubscriptionManager is not a function`?

Running:

import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
    schema,
    pubsub
});
setup(schema, {
  subscriptionManager
});

..brings up this message:

TypeError: SubscriptionManager is not a function

Stepping through the code, I noticed that SubscriptionManager was null after the import statement. I checked the GitHub page for graphql-subscriptions, and found:

SubscriptionManager @deprecated
SubscriptionManager is the previous alternative for using graphql-js subscriptions directly, and it's now deprecated.

What's the correct way to update access to Swydo:ddp-apollo now that SubscriptionManager has been deprecated?

Thanks very much in advance for the info.

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.6.0 to 6.7.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v6.7.0
  • 312a88f New: Add grouped-accessor-pairs rule (fixes #12277) (#12331) (Milos Djermanovic)
  • 5c68f5f Update: Add 'lexicalBindings' to no-implicit-globals and change messages (#11996) (Milos Djermanovic)
  • 6eaad96 New: Add suggestions API (#12384) (Will Douglas)
  • b336fbe Fix: indent rule with JSX spread props (#12581) (Nathan Woltman)
  • 97c745d Update: Report assignment expression location in no-cond-assign (#12465) (Milos Djermanovic)
  • 0f01f3d Update: Check member expressions with this in operator-assignment (#12495) (Milos Djermanovic)
  • 62c7038 Fix: invalid token checking in computed-property-spacing (fixes #12198) (#12533) (YeonJuan)
  • 4f8a1ee Update: Add enforceForClassMembers option to no-useless-computed-key (#12110) (ark120202)
  • 1a2eb99 New: new rule no-constructor-return (fixes #12481) (#12529) (Pig Fang)
  • ca3b2a6 New: ignorePatterns in config files (refs eslint/rfcs#22) (#12274) (Toru Nagashima)
  • 60204a3 Docs: Added another Textmate 2 bundle. (#12580) (Ryan Fitzer)
  • 62623f9 Fix: preserve whitespace in multiline-comment-style (fixes #12312) (#12316) (Kai Cataldo)
  • 17a8849 New: Add no-dupe-else-if rule (fixes #12469) (#12504) (Milos Djermanovic)
  • 41a78fd Update: improve location for semi and comma-dangle (#12380) (Chiawen Chen)
  • 0a480f8 Docs: Change "Code Conventions" link in pull-requests.md (#12401) (Denis Sikuler)
  • fed20bb Fix: require-await crash on global await (#12571) (Brad Zacher)
  • b8030fc Update: deprecate personal config (fixes #11914, refs eslint/rfcs#32) (#12426) (Toru Nagashima)
  • 40c8c32 Fix: improve report location for object-curly-spacing (#12563) (Milos Djermanovic)
  • 1110045 Fix: ignore marker-only comments in spaced-comment (fixes #12036) (#12558) (Milos Djermanovic)
  • 6503cb8 Update: Fix uglified object align in key-spacing (fixes #11414) (#12472) (YeonJuan)
  • 40791af Docs: clarify ignoreDestructuring option in the camelcase rule (#12553) (Milos Djermanovic)
  • 07d398d Chore: Add GitHub organization to Sponsor button (#12562) (Brandon Mills)
  • a477707 Chore: Format style guide links so they can be clicked (#12189) (Ivan V)
  • 0f7edef Update: add react plugin config for eslint init (#12446) (Ibrahim Rouis)
  • 448ff1e Update: Report '\08' and '\09' in no-octal-escape (fixes #12080) (#12526) (Milos Djermanovic)
  • 45aa6a3 New: Add no-setter-return rule (fixes #12285) (#12346) (Milos Djermanovic)
  • 0afb518 Fix: invalid autofix in function-call-argument-newline (fixes #12454) (#12539) (YeonJuan)
  • 90305e0 Update: Depcrecate isSpaceBetweenTokens() (#12519) (Kai Cataldo)
  • 41b1e43 New: add option for camelcase (fixes #12527) (#12528) (Pig Fang)
  • f49f1e0 Upgrade: upgrade optionator to avoid license issue (fixes #11536) (#12537) (Pig Fang)
  • 0286b57 Docs: Clean up Getting Started Guide (#12544) (Nicholas C. Zakas)
  • 575a98d Chore: Add funding field to package.json (#12543) (Nicholas C. Zakas)
  • 9e29e18 Fix: sourceCode#isSpaceBetweenTokens() checks non-adjacent tokens (#12491) (Kai Cataldo)
  • 5868550 Docs: add notice about function keyword in keyword-spacing (#12524) (Pig Fang)
  • bb556d5 Fix: curly multi reports single lexical declarations (fixes #11908) (#12513) (Milos Djermanovic)
  • ac60621 Fix: unexpected autofix in prefer-const (fixes #12514) (#12521) (YeonJuan)
  • 990065e Update: curly multi-or-nest flagging semis on next line (fixes #12370) (#12378) (cherryblossom000)
  • 084a8a6 Fix: no-cond-assign with always option reports switch case clauses (#12470) (Milos Djermanovic)
  • 7e41355 Update: improve report location for space-infix-ops (#12324) (Chiawen Chen)
  • 94ff921 Update: Add capIsConstructor option to no-invalid-this (fixes #12271) (#12308) (Milos Djermanovic)
  • de65de6 New: Add prefer-exponentiation-operator rule (fixes #10482) (#12360) (Milos Djermanovic)
  • c78f4a7 Update: Allow JSX exception in no-inline-comments (fixes #11270) (#12388) (Milos Djermanovic)
  • e17fb90 New: allowAfterThisConstructor for no-underscore-dangle (fixes #11488) (#11489) (sripberger)
  • 287ca56 Build: update CI for Node.js 13 (#12496) (Toru Nagashima)
  • 98e1d50 Upgrade: globals to v12.1.0 (#12296) (Tony Brix)
  • 8ac71a3 Sponsors: Sync README with website (ESLint Jenkins)
  • 4e142ea Docs: Update README team and sponsors (ESLint Jenkins)
Commits

The new version differs by 49 commits.

  • 61848b4 6.7.0
  • 9162db9 Build: changelog update for 6.7.0
  • 312a88f New: Add grouped-accessor-pairs rule (fixes #12277) (#12331)
  • 5c68f5f Update: Add 'lexicalBindings' to no-implicit-globals and change messages (#11996)
  • 6eaad96 New: Add suggestions API (#12384)
  • b336fbe Fix: indent rule with JSX spread props (#12581)
  • 97c745d Update: Report assignment expression location in no-cond-assign (#12465)
  • 0f01f3d Update: Check member expressions with this in operator-assignment (#12495)
  • 62c7038 Fix: invalid token checking in computed-property-spacing (fixes #12198) (#12533)
  • 4f8a1ee Update: Add enforceForClassMembers option to no-useless-computed-key (#12110)
  • 1a2eb99 New: new rule no-constructor-return (fixes #12481) (#12529)
  • ca3b2a6 New: ignorePatterns in config files (refs eslint/rfcs#22) (#12274)
  • 60204a3 Docs: Added another Textmate 2 bundle. (#12580)
  • 62623f9 Fix: preserve whitespace in multiline-comment-style (fixes #12312) (#12316)
  • 17a8849 New: Add no-dupe-else-if rule (fixes #12469) (#12504)

There are 49 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

setupHttpEndpoint is not a function

Want to use Http with ddp-apollo but got that error. this is my code.
import { setup, setupHttpEndpoint } from 'meteor/swydo:ddp-apollo';
import { makeExecutableSchema } from 'graphql-tools';
import typeDefs from '../../api/schema.js';
import resolvers from '../../api/resolvers.js';

const schema = makeExecutableSchema({ typeDefs, resolvers });
setupHttpEndpoint({ schema });

An in-range update of eslint-plugin-import is breaking the build 🚨

Version 2.4.0 of eslint-plugin-import just got published.

Branch Build failing 🚨
Dependency eslint-plugin-import
Current Version 2.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-plugin-import is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 10 commits.

  • 44ca158 update utils changelog
  • a3728d7 bump eslint-module-utils to v2.1.0
  • 3e29169 bump v2.4.0
  • ea9c92c Merge pull request #737 from kevin940726/master
  • 8f9b403 fix typos, enforce type of array of strings in allow option
  • 95315e0 update CHANGELOG.md
  • 28e1623 eslint-module-utils: filePath in parserOptions (#840)
  • 2f690b4 update CI to build on Node 6+7 (#846)
  • 7d41745 write doc, add two more tests
  • dedfb11 add allow glob for rule no-unassigned-import, fix #671

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Does it support mutation over http?

Hello,

I have tried to use mutation over http but got TypeError: Must provide Source. Received: undefined error. I guess it wasn't supporting mutation yet. May I right?

meteor-ddp-apollo-gateway

meteor-ddp-apollo-gateway

hello every one, i want an api gateway where merge all my remotes schemas, any example???
thanks

Errors array doesn't provide useful errors

I've got a relatively straightforward server configuration following the README. Whenever an error bubbles up to the GraphQL server level, the errors array in the response looks like this:

{
  "errors": [
    {}
  ],
  "data": {
    "myMutation": null
  }
}

This isn't very helpful for debugging errors. I'm going to investigate why errors seem to be swallowed up but I just thought I'd check in to see if anyone else is having this problem?

Subscription Component Error? [FIXED]

I have a subscription component that looks like this:

        <Subscription
            subscription={INCOMING_MESSAGES_SUBSCRIPTION_QUERY}
            variables={{"localUserId": Meteor.userId()}}
        >
            {({data, loading}) => (
                <h4>New comment:</h4>
            )}
        </Subscription>

I'm getting an error on the server that looks like this:

Exception in onStop callback: TypeError: iterator.return is not a function
at Subscription.onStop (packages/swydo:ddpapollo/lib/server/createGraphQLPublication.js:55:27)

How do I correct this?

UPDATE: FIXED
It was a mismatch between my schema definition and my query definition. This is the incorrect way it used to be set up:

Schema

  IncomingMessage_Subscription(localUserId: String!): IncomingMessage

Query

const INCOMING_MESSAGES_SUBSCRIPTION_QUERY = gql`
    subscription ($localUserId: String!){
        IncomingMessage_Subscription(userId: $localUserId){
            msgType: String
            remoteUserId: String
            remoteUserData: epUserData
            VideoCall: VideoCall
            instantMessage: instantMessages
        },
    }
`;

The param name didn't match in the schema vs. the query. It needed to be userId in both places.

Meteor package depends on apollo-link-ddp client code.

Because meteor/swydo:ddp-link requires an install of apollo-link-ddp, we also need to install the npm package graphql.

} from 'apollo-link-ddp';

These result in 2 graphql packages in the node_modules directory and conflicts.

Exception while invoking method '__graphql' TypeError: execute is not a function
at Promise.asyncApply (packages/swydo:ddp-apollo/lib/server/createGraphQLMethod.js:28:12)

I would prefer not importing the Apollo Link DDP npm module for the client in the server code.

meteor/meteor and apollo-link-http are needed to use apollo-link-ddp

I have a react-native project and want to use apollo-link-ddp with simpleddp but I'm getting following error:

Error: Unable to resolve module meteor/meteorfromnode_modules/apollo-link-ddp/dist/client/apollo-link-ddp.js: meteor/meteor could not be found within the project.

Is there some kind of workaround?
Here is my current code:

import { ApolloClient, InMemoryCache } from '@apollo/client';
import SimpleDDP from 'simpleddp';
import { simpleDDPLogin } from 'simpleddp-plugin-login';
import { DDPLink } from 'apollo-link-ddp';

const ddp = new SimpleDDP({
  endpoint: 'ws://localhost:3000/websocket',
  SocketConstructor: global.WebSocket,
   reconnectInterval: 5000,
}, [simpleDDPLogin]);
     
const client = new ApolloClient({
 link: new DDPLink({
 connection: ddp,
 socket: ddp.ddpConnection.socket,
}),
 cache: new InMemoryCache(),
});

Separate package for Non-Meteor client?

I am using meteor as our backend, but not for the frontend. I digging in the code and find the client part is relied on Meteor package. So, we modify it to not depends on meteor library.

Any chance to separate the client part, so we can use with other framework easily?

Why is `graphql-subscriptions` not recommended for production?

// The pubsub mechanism of your choice, for instance:
// - PubSub from graphql-subscriptions (not recommended for production)
// - RedisPubSub from graphql-redis-subscriptions
// - MQTTPubSub from graphql-mqtt-subscriptions

Can you explain why graphql-subscriptions is not recommended for production? I'm curious because you're using DDP, and Meteor is using that in production just fine.

Or is it not the transport that's limited, but the way it's observing changes to be pushed? Would mongo changeStreams change something in this case?

I'm looking for an easy integration with Meteor, and hoping to avoid to implement and maintain another system (redis / mqtt). Can we not use Meteor's publish and subscribe to create an easy-to-implement subscription handler?

cannot config HTTP support

hi, i'm having a strange problem with this fantastic lib.
Everything worked fine, when i used the base config, greate job. But now, i have to attach my meteor server to a react native app by using react-native-meteor.
So first thing i have to do is add the http support to allow my rn app to connect, right?
i followed the guide in HTTP support, i replaced the client/server configs, but i'm having two problems:

when i access to http://localhost:3000/graphql, it gives me:
TypeError: Must provide Source. Received: undefined

then in my subscription
Exception in onStop callback: TypeError: iterator.return is not a function
and the subscription doesn't get triggered by calling pubsub.publish()

any ideas?

An in-range update of eslint-config-airbnb-base is breaking the build 🚨

Version 11.3.0 of eslint-config-airbnb-base just got published.

Branch Build failing 🚨
Dependency eslint-config-airbnb-base
Current Version 11.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-config-airbnb-base is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

DDPLink Undefined After `import { DDPLink } from 'meteor/swydo:ddp-apollo'`?

After import { DDPLink } from 'meteor/swydo:ddp-apollo';, DDPLink appears to be undefined. I ran meteor update swydo:ddp-apollo to make sure I had the latest version.

import { DDPLink } from 'meteor/swydo:ddp-apollo';
import { InMemoryCache } from 'apollo-cache-inmemory';

const client = new ApolloClient ({
  link: new DDPLink({     //<== console message "DDPLink is not a constructor"
    connection: Meteor.connection
  }),
  cache: new InMemoryCache()
});

How can I correct this? Thanks in advance for the info!

Subscriptions not working with Meteor version 1.8.2

When updating to Meteor version 1.8.2 Apollo Client doesn't receive subscription notifications.

I've updated the Starter Kit from original version (1.5.4.2) to version 1.8.1 successfully but when updating to version 1.8.2 it stops working.

Thank you very much in advanced.

Subscription Not Connecting?

As a method of learning Swydo ddp-apollo, I'm adapting Michael C. Brook's Apollo 2.0 GraphQL + subscriptions demo to use Swydo ddp-apollo.

I think I've followed all the Swydo docs, but for some reasons subscriptions are not quite connecting yet.

Error: Network error: Internal server error [500]
    at new ApolloError (modules.js?hash=7db0afb9c299b19ce1ce8262b6c4a7aadce088a1:1083)
    at Object.error (modules.js?hash=7db0afb9c299b19ce1ce8262b6c4a7aadce088a1:1799)
    at SubscriptionObserver.error (modules.js?hash=7db0afb9c299b19ce1ce8262b6c4a7aadce088a1:19642)
    at apollo-link-ddp.js:21
    at MethodInvoker._callback (meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:1117)
    at MethodInvoker._maybeInvokeCallback (livedata_connection.js:440)
    at MethodInvoker.receiveResult (livedata_connection.js:460)
    at Connection._livedata_result (livedata_connection.js:1629)
    at onMessage (livedata_connection.js:278)
    at stream_client_sockjs.js:174

The demo app is attached.

swydo-demo-based-on-meteor-apollo2-master.zip

The 500 error appears after clicking the "Update" button in the demo app.

What am I missing?

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

Version 2.7.0 of eslint-plugin-import just got published.

Branch Build failing 🚨
Dependency eslint-plugin-import
Current Version 2.6.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-plugin-import is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits.

  • c9dd91d bump to v2.7.0
  • ee5a986 changelog note for #843
  • 0dc4451 Merge branch 'no-absolute-path-perf'
  • f70d127 upgraded no-absolute-path to use moduleVisitor pattern to support all module systems
  • e4b8884 PR note fixes
  • 5aa2fe0 Rename funtion reportIfMissing to reportIfAbsolute
  • 3e8438e Extract isAbsolutePath from importTypes helper

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Investigate ClientStream usage

Maybe we can make use of the recent refactoring of the ClientStream and DDP packages and remove the dependency on DDP and use ClientStream directly, making this package more flexible (a.k.a. less hackish in some ways).

See meteor/meteor#9371

Thinks to look into:

  • Authentication
  • Subscribing to data

An in-range update of simpleddp is breaking the build 🚨

The devDependency simpleddp was updated from 2.0.1 to 2.0.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

simpleddp is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of apollo-link is breaking the build 🚨

There have been updates to the apollo-link monorepo:

  • The devDependency apollo-link was updated from 1.2.11 to 1.2.12.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the apollo-link group definition.

apollo-link is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 92 commits.

  • f902ab9 chore: Publish
  • 242d216 Update CHANGELOG.md before publishing new versions.
  • 8488a84 chore(deps): update dependency rollup to v1.15.4
  • eb37c19 chore(deps): update dependency rollup to v1.15.2
  • cf58af0 chore(deps): update dependency @types/jest to v24.0.14
  • 19def9b chore(deps): update dependency rollup to v1.15.1
  • bc4a4be Merge pull request #1083 from apollographql/upgrade-theme
  • 71eccd8 Upgrade docs theme to 1.0.6
  • 26d6f0e chore(deps): update dependency rollup to v1.15.0
  • 951217b chore(deps): update dependency rollup to v1.14.6
  • 3786284 chore(deps): update dependency rollup to v1.14.4
  • 28f0e20 Merge pull request #1074 from apollographql/upgrade-theme
  • 7b8b3d7 Upgrade docs theme to latest
  • 6c0b46b chore(deps): update dependency rollup to v1.14.3
  • b0ac061 Merge pull request #1069 from callmenick/patch-1

There are 92 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Support for file uploading?

Does ddp-apollo support file uploading?

Earlier, I had successfully used apollo-upload-server and apollo-upload-client, with a dedicated upload link.

The Apollo docs seem to suggest that file uploads are now supposed to be working without any extra packages (like the aforementioned apollo-upload-server and apollo-upload-client, and it doesn't mention any restrictions on the link. However, I can't make it to work over ddp-apollo. Have you tested this? Is this supposed to be working? Is there an example somewhere?

Thank you for explaining.

TypeError: iterator.return is not a function?

UPDATE

This anomaly turns out to have nothing to do with PWA. Please skip to the 3rd post in this thread.


I found this very elegant article, "Transform any Meteor App into a PWA". It was very easy to follow and implement.

When I run my app after implementing this, I see this in my server console logs:

20200520-21:41:50.650(-7)? Exception in onStop callback: TypeError: iterator.return is not a function
I20200520-21:41:50.650(-7)?     at Subscription.<anonymous> (packages/swydo:ddp-apollo/lib/server/createGraphQLPublication.js:56:27)
I20200520-21:41:50.650(-7)?     at runWithEnvironment (packages/meteor.js:1286:24)
I20200520-21:41:50.650(-7)?     at packages/meteor.js:1299:14
I20200520-21:41:50.650(-7)?     at packages/ddp-server/livedata_server.js:1158:7
I20200520-21:41:50.650(-7)?     at Array.forEach (<anonymous>)
I20200520-21:41:50.651(-7)?     at Function._.each._.forEach (packages/underscore.js:139:11)
I20200520-21:41:50.651(-7)?     at Subscription._callStopCallbacks (packages/ddp-server/livedata_server.js:1157:7)
I20200520-21:41:50.651(-7)?     at Subscription._deactivate (packages/ddp-server/livedata_server.js:1147:10)
I20200520-21:41:50.651(-7)?     at Session._stopSubscription (packages/ddp-server/livedata_server.js:873:18)
I20200520-21:41:50.651(-7)?     at Subscription.stop (packages/ddp-server/livedata_server.js:1215:19)
I20200520-21:41:50.651(-7)?     at packages/swydo:ddp-apollo/lib/server/createGraphQLPublication.js:68:24
I20200520-21:41:50.651(-7)?     at /Users/vikrubenfeld-2020/.meteor/packages/promise/.0.11.2.158ss2l.tikp++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40

Is there a best practices way of adding PWA to a Meteor/Swydo ddp-apollo app yet?

Thanks very much in advance for any info!

An in-range update of graphql-tag is breaking the build 🚨

Version 2.3.0 of graphql-tag just got published.

Branch Build failing 🚨
Dependency graphql-tag
Current Version 2.2.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As graphql-tag is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

How to get socket connection ID?

Here is what I am trying to do:

  • Let the clients connect to the server using a normal Meteor socket, using DDP
  • Use meteor auth normally
  • Create a DDP-Apollo meteor link on top of the existing socket and DDP link
  • Use the normal meteor auth info inside my Apollo context
  • Using Meteor.onConnection(), keep track of all my existing clients, based on the unique connection ID
  • Access the connection ID in my Apollo context, so that I can identify not only the user, but also the individual client instance.

The difficulty is that in the function creating the context, I can't access any information that I could use to achieve the last step. I have a headers object, what what I need in the connection ID of the socket, and not any headers. Is there a way to get that? I guess it could be extracted at the same time when we also get the meteor user name.

custom context

Hello, I am trying to figure out how to add my own objects to the context:

setup({
  schema,
  context: {
    Ciudad: new Ciudad(),
    Oficina: new Oficina(),
  },
});

So later I can use the instantiated objects (Ciudad and Oficina) in my resolvers trough context.
Can you point me in the right direction? thank you

MeteorLink is not a function

i updated to 1.4.0-beta2 to use http combine with engine, but when i use new MeteorLink() on client, console show error : Uncaught TypeError: MeteorLink is not a function , i also tried print MeteorLink on console and it show undefined, am i missing something?

An in-range update of apollo-cache-inmemory is breaking the build 🚨

Version 1.1.1 of apollo-cache-inmemory was just published.

Branch Build failing 🚨
Dependency apollo-cache-inmemory
Current Version 1.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

apollo-cache-inmemory is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Confused about subscriptions

I don't have a lot of GraphQL knowledge currently, but I'm confused about subscriptions.

From what I understand, I need to use a PubSub of some sort, such as redis? Does this mean that the standard Mongo subscription over DDP is not available, and all my mutations need to push updates specifically, and I can't just rely on Mongo watching the oplog any longer? That is, we cannot use any DDP-like subscriptions?

Perhaps a simple example of a Mongo collection being written to and read in the starter example app may help, that isn't just time-based local update, but one that writes all the way to Mongo, and gets updates via the subscribe mechanism would be helpful.

Can i use engine on DDP?

like question, i want engine for monitor my data, but engine only work on HTTP not on DDP, i don't want drop DDP , is there way force engine work with ddp ?

Question: ddp-apollo for Meteor-Subscription

Can this package be used to enable only meteor pub-sub on the GraphQL server working with an Apollo-Client?
There is a DDPSubscriptionLink but don't know if this is only to enable Meteor-DDP on an HTTP (GraphQL) server or it is for using DDP on a server configured with this package.
I have an already configure server that only needs DDP (Meteor-pub-sub´) capability so that I can just Meteor.publishon theserverandMeteor.subscribeon theclient.`

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.3.0 to 6.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.4.0
  • e915fff Docs: Improve examples and clarify default option (#12067) (Yuping Zuo)
  • 540296f Update: enforceForClassMembers option to accessor-pairs (fixes #12063) (#12192) (Milos Djermanovic)
  • d3c2334 Update: flag nested block with declaration as error (#12193) (David Waller)
  • b2498d2 Update: Fix handling of property names in no-self-assign (#12105) (Milos Djermanovic)
  • 1ee61b0 Update: enforceForClassMembers computed-property-spacing (fixes #12049) (#12214) (Milos Djermanovic)
  • 520c922 Docs: Added naming convention details to plugin usage (#12202) (Henrique Barcelos)
  • f826eab Fix: Allow line comment exception in object-curly-spacing (fixes #11902) (#12216) (Milos Djermanovic)
  • db2a29b Update: indentation of comment followed by semicolon (fixes #12232) (#12243) (Kai Cataldo)
  • ae17d1c Fix: no-sequences is reporting incorrect locations (#12241) (Milos Djermanovic)
  • 365331a Fix: object-shorthand providing invalid fixes for typescript (#12260) (Brad Zacher)
  • 1c921c6 New: add no-import-assign (fixes #12237) (#12252) (Toru Nagashima)
  • 3be04fd New: Add prefer-regex-literals rule (fixes #12238) (#12254) (Milos Djermanovic)
  • 37c0fde Update: Report global Atomics calls in no-obj-calls (fixes #12234) (#12258) (Milos Djermanovic)
  • 985c9e5 Fix: space-before-function-paren autofix removes comments (fixes #12259) (#12264) (Milos Djermanovic)
  • 01da7d0 Fix: eqeqeq rule reports incorrect locations (#12265) (Milos Djermanovic)
  • 319e4d8 Docs: adding finally example (#12256) (Jens Melgaard)
  • d52328f Docs: fix no-sequences with examples (#12239) (Milos Djermanovic)
  • a41fdc0 Fix: Remove autofixer for no-unsafe-negation (#12157) (Milos Djermanovic)
  • e38f5fd Update: fix no-octal-escape false negatives after \0 (#12079) (Milos Djermanovic)
  • 9418fbe Sponsors: Sync README with website (ESLint Jenkins)
  • acc5ec5 Sponsors: Sync README with website (ESLint Jenkins)
  • 460c5ad Sponsors: Sync README with website (ESLint Jenkins)
  • 0313441 New: add rule default-param-last (fixes #11361) (#12188) (Chiawen Chen)
  • 7621f5d Update: add more specific linting messages to space-in-parens (#11121) (Che Fisher)
  • 21eb904 Fix: basePath of OverrideTester (fixes #12032) (#12205) (Toru Nagashima)
  • 86e5e65 Sponsors: Sync README with website (ESLint Jenkins)
  • 2b1a13f Fix: no-extra-boolean-cast reports wrong negation node (fixes #11324) (#12197) (Milos Djermanovic)
  • ba8c2aa Sponsors: Sync README with website (ESLint Jenkins)
  • a0a9746 Docs: Fix link in no-irregular-whitespace.md (#12196) (Timo Tijhof)
  • e10eeba Fix: quotes autofix produces syntax error with octal escape sequences (#12118) (Milos Djermanovic)
Commits

The new version differs by 32 commits.

  • 5f3024f 6.4.0
  • c847be2 Build: changelog update for 6.4.0
  • e915fff Docs: Improve examples and clarify default option (#12067)
  • 540296f Update: enforceForClassMembers option to accessor-pairs (fixes #12063) (#12192)
  • d3c2334 Update: flag nested block with declaration as error (#12193)
  • b2498d2 Update: Fix handling of property names in no-self-assign (#12105)
  • 1ee61b0 Update: enforceForClassMembers computed-property-spacing (fixes #12049) (#12214)
  • 520c922 Docs: Added naming convention details to plugin usage (#12202)
  • f826eab Fix: Allow line comment exception in object-curly-spacing (fixes #11902) (#12216)
  • db2a29b Update: indentation of comment followed by semicolon (fixes #12232) (#12243)
  • ae17d1c Fix: no-sequences is reporting incorrect locations (#12241)
  • 365331a Fix: object-shorthand providing invalid fixes for typescript (#12260)
  • 1c921c6 New: add no-import-assign (fixes #12237) (#12252)
  • 3be04fd New: Add prefer-regex-literals rule (fixes #12238) (#12254)
  • 37c0fde Update: Report global Atomics calls in no-obj-calls (fixes #12234) (#12258)

There are 32 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Subscriptions are sometimes immediately unsubbed again

Following setup:

I have a <Parent/> React component which uses the standard withTracker() HOC to load some stuff from normal Meteor subscriptions.
The wrapper <Parent/> then uses a standard logic in its render function like so: if(this.props.loading) return <Loading/>; // ... return <ReactiveQuery .../>

I wrote myself a little DDP message debugger based on this: https://stackoverflow.com/questions/25373648/how-to-view-meteor-ddp-traffic

Using this I can monitor subs and unsubs.

Following problem:
If the <Parent/> displays <Loading/> at least once before displaying the actual <ReactiveQuery .../> the subscription is immediately canceled again after subbing!

When I remove the if(this.props.loading) return <Loading/>; the subscription works just fine, although I have more (re-) renders obviously.

The problem is, that I can NOT simply remove if(this.props.loading) return <Loading/>; in my actual production app, since there are many more child components depending on the data loaded inside the withTracker() HOC. These are broken after remove the if(loading).

Anyone ever experienced this? I just don't understand what exactly is causing this behavior, but this is completely breaking my app because I really need this subscriptions to work!

Hope someone can help, thanks guys!

integrating ddp-apollo with cleverbeagle/pup

Hello,
I am working on a project where a choice have been made to use the cleverbeagle/pup boilerplate

Pup is built on top of meteor, and it's supports graphql subscriptions , except the fact that it creates another server to support that.

Here is how the subscription server is intialized

import http from 'http';
import { SubscriptionServer } from 'subscriptions-transport-ws';
import { execute, subscribe } from 'graphql';
import { makeExecutableSchema } from 'graphql-tools';
import validators from './lib/validators';

module.exports = (options) => {
  validators.options(options);
  
  // NOTE: Conditionally load apollo-server variant if user has an existing server.
  const existingWebServer = options.config && options.config.existingWebServer;
  const existingWebSocketServer = options.config && options.config.existingWebSocketServer;
  const { ApolloServer, PubSub } = existingWebServer ? require('apollo-server-express') : require('apollo-server');

  const pubsub = new PubSub();
  const server = new ApolloServer({
    ...options.schema,
    context: async (params) => {
      const customContext = options.context ? await options.context(params) : {};
      return {
        pubsub,
        ...customContext,
      };
    },
    uploads: false,
  });

  if (existingWebServer) {
    server.applyMiddleware({
      app: existingWebServer,
      path: options.config.path || '/graphql',
    });
  } else {
    server.listen({ port: options && options.config && options.config.port || 4000 }).then(({ url }) => {
      console.log(`[PupQL] Woof! Your GraphQL server is ready at ${url}`);
    });
  }

  const websocketServer = http.createServer((request, response) => {
    response.writeHead(200);
    response.end();
  });

  websocketServer.listen(4001);

  SubscriptionServer.create({
    schema: makeExecutableSchema({ ...options.schema }),
    execute,
    subscribe,
    onConnect: () => {
      console.log(`[PupQL] Woof! Subscription client connected...`);
      return { pubsub };
    },
    onDisconnect: () => {
      console.log(`[PupQL] Woof! Subscription client disconnected...`);
    }
  }, {
    server: websocketServer,
    path: '/graphql',
  });

  // NOTE: Centralize handling of nested Promise errors here so we don't
  // have to have a bunch of .catch() callbacks and repetition.
  if (process && process.on) {
    process.on('unhandledRejection', (error) => {
      console.warn(`[PupQL] ${error}`);
    });  
  }

  return server;
};

How can I change this to use the existing meteor's websocket server?

I am kind of lost.
Thanks in advance for any information/help

An in-range update of graphql-server-core is breaking the build 🚨

Version 0.8.2 of graphql-server-core just got published.

Branch Build failing 🚨
Dependency graphql-server-core
Current Version 0.8.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As graphql-server-core is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Can we easily integrate GraphiQL ?

Awesome package, works like a charm!

It would be nice if you could integrate GraphiQL out-of-the-box inside here like it's on meteor-apollo package.

Any plans on doing that ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.