Skip to content
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

Is there a way to save the mutations to the db.js file? #96

Closed
aaronksaunders opened this issue Aug 24, 2020 · 2 comments
Closed

Is there a way to save the mutations to the db.js file? #96

aaronksaunders opened this issue Aug 24, 2020 · 2 comments

Comments

@aaronksaunders
Copy link

Apologies for question here, wasn't clear from "contributing guidelines" what the alternative was

I was expecting that changes/mutation to the database would be updated in db.js, any suggestion on how to make that happen. The changes are all in the InMemoryCache,but there are no updated in the file

@djhi
Copy link
Contributor

djhi commented Aug 24, 2020

Yes, it is an in memory database. There are no mechanisms in place to export the data.

@djhi djhi closed this as completed Aug 24, 2020
@richcorbs
Copy link

I found that I could access the data using this pattern in the "on finish" event:

const express = require('express')
const jsonGraphqlExpress = require('json-graphql-server').default

const data = { dogs: [{ id: 1, name: 'pepper' }] };
const app = express();

app.use(function(req, res, next) {
  console.log("before", data);

  res.on("finish", function() {
      console.log("after", data);
  });
  next();
});

app.use('/graphql', jsonGraphqlExpress(data));

const PORT = 5555;
app.listen(PORT, (err) => {
  console.log(`GraphQL server listening on port ${PORT}`)
});

Maybe this will help others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants