Giter VIP home page Giter VIP logo

graphql-bookshelf's Introduction

Hi there πŸ‘‹

I have a lot of open source projects to keep up, so sometime I get a little behind, but I've doubled down on my commitment to be a good maintainer. Let me know if something is getting in your way.

You can look at my website, or look through my blog. Or you can see all my project's status badges in one place. Just don't judge too hard, I just started getting serious about this overhaul / cleanup so I have some work to do.

graphql-bookshelf's People

Contributors

andreaorru avatar brysgo avatar gitter-badger avatar greenkeeper[bot] 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

graphql-bookshelf's Issues

Optimization for relations of relation

I have created a small example where the model is like the following

 Student --- hasMany ---> Homework --- hasMany -----> Page

Now, when I load the following (note: viewer is the student) the there is one query for the student, one for the homework, but multiple for the pages. There are as many queries as there are pages. How can i optimize it so that there is only one query for the all the pages.

Best case scenario would be to load the whole thing at once, but i'd be happy for any pointers on how to optimize this.

{ 
 viewer(id: 3) {
    name
    homeworks{
      subject
      pages{
        content
      }
    }
  }
}

The code i used to test this is available at https://gist.github.com/hardfire/3ff69d3a602bf3c30dcbbca71d67d605

Unsure of what this library is providing exactly..

Hey there,

I'm interested in this library because I'm currently using bookshelf in an app and am curious about graphql. I've peeked at the source code and tests a few times now, but don't quite grok what the point of this library is.. Is the idea that you can use the bookshelf models you've already defined within your graphql types?

I think it would be nice if a clearer explanation existed on the readme describing the problem this library is trying to solve as well as what its philosophy is.

Thanks very much,
Thomas

Only load relations as needed

Hello, great library! I've been evaluating it and had a question about using the hasMany helper function. If you specify that a BookshelfType hasMany of something else, it looks like here in the code that it loads the relation as a second query. Is that correct?

Also, instead of using this.constructor.collection to call the static method on L31 I believe you could use BookshelfType.collection

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

The devDependency graphql was updated from 14.3.0 to 14.3.1.

🚨 View failing branch.

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

graphql 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
  • ❌ ci/circleci: Your tests failed on CircleCI (Details).

Release Notes for v14.3.1

14.3.1 (2019-05-23)

Bug Fix 🐞

Polish πŸ’…

19 PRs were merged

Internal 🏠

15 PRs were merged

Committers: 2

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 🌴

Caching/batching option

I think we should try and build caching and or batching into bookshelf. This framework will not scale very well until this optimization is made.

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

Version 0.14.2 of knex was just published.

Branch Build failing 🚨
Dependency knex
Current Version 0.14.1
Type devDependency

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

knex 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 2 commits.

  • aac0565 Updated change log + version for 0.14.2
  • b5ba51a Fix truncate() on sqlite3 dialect (#2348)

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 🌴

Mutation Example

Hey, thanks for the great work, but I'm curious, how would you go about using this library to do mutations?

expected iterable, but did not find one for field Query.XXXX

Hello! I'm trying to wire up a User model with two GraphQL query fields.

The type:

const userType = new GraphQLObjectType(BookshelfType({
  name: 'User',
  description: 'A user',
  fields: model => ({
    id: globalIdField('User'), // Relay stuff
    email: model.attr({
      type: GraphQLString,
    }),
    role: model.attr({
      type: GraphQLString,
    }),
  }),
  interfaces: [nodeInterface], // Relay stuff
}));

The schema:

const queryType = new GraphQLObjectType({
  name: 'Query',
  fields: () => ({
    node: nodeField,
    users: {
      type: new GraphQLList(userType),
      resolve: () => User.fetchAll(),
    },
    user: {
      args: {
        id: { type: GraphQLInt },
      },
      type: userType,
      resolve: (_, args) => User.forge({ id: args.id }).fetch(),
    },
  }),
});

export default new GraphQLSchema({
  query: queryType,
});

I can query one user just fine with { user(id: 1) { id, email, role } }.

However, if I query the all users field { users { id, email, role } } I get this error: User Error: expected iterable, but did not find one for field Query.users.

I guess it's complaining about type: new GraphlQLList(userType) as return type? It's expecting an iterable but gets a Bookshelf Collection, right?

If I force it to return an array instead of a collection it works:

// I change
resolve: () => User.fetchAll()
// to:
resolve: () => User.fetchAll().then(users => users.reduce((arr, user) => { arr.push(user); return arr; }, [])),

What am I doing wrong here?

Relay helpers

It is still unclear to me what the best approach for building a relay compatible schema with graphql bookshelf is.

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.