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

Example doesn't work #7

Open
RedShift1 opened this issue Dec 31, 2017 · 1 comment
Open

Example doesn't work #7

RedShift1 opened this issue Dec 31, 2017 · 1 comment

Comments

@RedShift1
Copy link

Code here: https://gist.github.com/RedShift1/cb60eb8fc67fbfc7cd823e907dd445d9
Database from https://github.com/acarl005/join-monster-graphql-tools-adapter/tree/master/db

The only change I made compared to the example was in the user resolver, wrapping the "return joinMonster" in a Promise.then(), because require('sqlite').open(...) returns a Promise.

Result:

C:\tmp\test>node index.js
{ data: { user: null } }

Dependency versions:
"dependencies": {
"graphql": "^0.12.3",
"graphql-tools": "^2.14.1",
"join-monster": "^2.0.15",
"join-monster-graphql-tools-adapter": "0.0.2",
"sqlite": "^2.9.0"
},

@IrinaShirinsky
Copy link

You have to use knex to connect to your database (https://knexjs.org/)
For example,

var pg = require('knex')({
  client: 'pg',
  connection: process.env.PG_CONNECTION_STRING,
  searchPath: ['knex', 'public'],
});

Once you added this, QueryRoot resolve method will work correctly.

        return joinMonster(resolveInfo, {}, sql => {
            // knex is a query library for SQL databases
            return knex.raw(sql);
          })

and data will be returned from your database.

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

2 participants