question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mutations in Meteor

See original GitHub issue

Hi, I’m using apollo-client with Meteor and default MongoDB. All queries work nicely, but none of my mutations seem to work as I’m getting the famous error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment

I tried wrapping it in AsyncCallback, I even tried to bind it to environment but nothing seems to workl 😭

const resolvers = {
  Query: {
    async posts(root, args) {
      return Posts.find({}).fetch();
    },
  Mutation: {
    async addPost(root, { title, content }) {
      let asyncCall = Meteor.bindEnvironment(function() {
        Posts.insert({ title: title, content: content });
        return Posts.find({}).fetch();
      });
      return asyncCall();
    },
  }
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
tomitrescakcommented, May 14, 2016

Thank you @stubailo that did it.

Still a noob here … but getting there. I know you guys are not a support forum for GraphQL so I really appreciate your responses. It’s just that your approach is a bit different (and I like it more) that what you find in the classic GraphQL examples online. I really love the way you just use schemas for the definition and separate resolvers. Awesome work! Thanks.

1reaction
abhiaiyer91commented, May 13, 2016

The minute you need to use bindEnvironment, and Fibers and all this complex stuff means Apollo didn’t do its job. And i know thats not the case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the steps to perform meteorite mutations? : r/ancestors
What are the steps to perform meteorite mutations? · bring 6 babies to meteor site. · inspect meteor site. · wait until you...
Read more >
4: Using GraphQL to Change Data - Meteor React Tutorial
Let's create a mutation to insert tasks, and once more start with the server side. We'll insert a save function inside the TasksCollection...
Read more >
Meteor Feet Mutation | The Eternal Cylinder Wiki - Fandom
Obtained from Barbagar's Foot. This mutation can be permanently activated by mixing 1 Barbagar's Foot, 2 Furtree Cones, and 3 Refined Minerals.
Read more >
cultofcoders:mutations - Packosphere
We go with Meteor on the road of CQRS and we want to separate fully the way we deal with fetching data and...
Read more >
Introduction To Mutations | Full-stack GraphQL with Apollo ...
Introduction To Mutations. In this free series, I'll be teaching GraphQL with Apollo, Meteor & React to build a full-stack app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found