Giter VIP home page Giter VIP logo

Comments (13)

chrissm79 avatar chrissm79 commented on July 19, 2024

@vestervang Thanks for the head's up! Let me take a look and see if I can reproduce and test it. But yes, there certainly seems to be an issue there.

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

@vestervang I used the lighthouse-example with the following schema:

type Task {
  title: String!
}

type User {
  name: String!
  email: String!
  jobs: [Job!]! @hasMany
}

type Job {
  id: ID!
  title: String!
  user: User @belongsTo
  tasks: [Task!]! @hasMany(type: "connection")
}

type Query {
  me: User @auth
  jobs: [Job!]! @paginate(type: "connection" model: "App\\Job")
}

Sent this query:

{
  jobs(first:1) {
    pageInfo {
      total
      startCursor
      endCursor
		}
    edges {
      cursor
      node {
        id
        title
        tasks(first:2) {
          pageInfo {
            total
            startCursor
            endCursor
          }
          edges {
            cursor
            node {
              title
            }
          }
        }
      }
    }
  }
}

and got the following response:

{
  "data": {
    "jobs": {
      "pageInfo": {
        "total": 30,
        "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
        "endCursor": "YXJyYXljb25uZWN0aW9uOjE="
      },
      "edges": [
        {
          "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
          "node": {
            "id": "1",
            "title": "Assumenda ea dolores illo facere.",
            "tasks": {
              "pageInfo": {
                "total": 3,
                "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
                "endCursor": "YXJyYXljb25uZWN0aW9uOjI="
              },
              "edges": [
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
                  "node": {
                    "title": "Repellendus et tempora eos doloribus odit corporis a aspernatur."
                  }
                },
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
                  "node": {
                    "title": "Consectetur aut nobis ut."
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Could you post the newsArticles relationship on your User model?

from lighthouse.

vestervang avatar vestervang commented on July 19, 2024

Sure thing

User.php

...
class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'username',
        'password',
        'email',
        'runescape_name',
        'member',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    public function newsArticles()
    {
        return $this->hasMany(NewsArticle::class);
    }

    public function newsArticleComments()
    {
        return $this->hasMany(NewsArticleComment::class);
    }
}

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

Man that's odd, that looks completely fine.. What DB and version are you using?

from lighthouse.

vestervang avatar vestervang commented on July 19, 2024

MySQL 5.7.21.

Everything works when testing in artisan tinker

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

Just to rule out something weird w/ the User model or the relation argument, I updated my version of the lighthouse-example schema to:

type Task {
  title: String!
}

type User {
  name: String!
  email: String!
  foo_bar: [Job!]! @hasMany(type: "connection", relation: "jobs")
}

type Job {
  id: ID!
  title: String!
  user: User @belongsTo
  tasks: [Task!]! @hasMany(type: "connection")
}

type Query {
  me: User @auth
  jobs: [Job!]! @paginate(type: "connection" model: "App\\Job")
  users: [User!]! @paginate(type: "connection" model: "App\\User")
}

ran this query:

{
  users(first:1) {
    pageInfo {
      startCursor
      endCursor
      total
    }
    edges {
      cursor
      node {
        email
        foo_bar(first: 2) {
          pageInfo {
            startCursor
            endCursor
            total
          }
          edges {
            cursor
            node {
              id
            }
          }
        }
      }
    }
  }
}

but I still got the expected output:

{
  "data": {
    "users": {
      "pageInfo": {
        "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
        "endCursor": "YXJyYXljb25uZWN0aW9uOjE=",
        "total": 10
      },
      "edges": [
        {
          "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
          "node": {
            "email": "[email protected]",
            "foo_bar": {
              "pageInfo": {
                "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
                "endCursor": "YXJyYXljb25uZWN0aW9uOjI=",
                "total": 3
              },
              "edges": [
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
                  "node": {
                    "id": "1"
                  }
                },
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
                  "node": {
                    "id": "2"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Can you run composer update nuwave/lighthouse just to confirm you have the most updated version?

from lighthouse.

vestervang avatar vestervang commented on July 19, 2024

Just updated my composer. No updates for lighthouse.

I'm running "nuwave/lighthouse": "dev-master"

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

I pulled down dev-master and even nested another level but I'm still getting the correct pageInfo. Could you try to reproduce the error w/ the lighthouse-example repo or if you could create a new repo for me to debug that would be great!

{
  users(first:1) {
    pageInfo {
      startCursor
      endCursor
      total
    }
    edges {
      cursor
      node {
        email
        foo_bar(first: 2) {
          pageInfo {
            startCursor
            endCursor
            total
            hasNextPage
          }
          edges {
            cursor
            node {
              id
              tasks(first:3) {
                pageInfo {
                  startCursor
                  endCursor
                  total
                  hasNextPage
                }
                edges {
                  cursor
                  node {
                    title
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
{
  "data": {
    "users": {
      "pageInfo": {
        "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
        "endCursor": "YXJyYXljb25uZWN0aW9uOjE=",
        "total": 10
      },
      "edges": [
        {
          "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
          "node": {
            "email": "[email protected]",
            "foo_bar": {
              "pageInfo": {
                "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
                "endCursor": "YXJyYXljb25uZWN0aW9uOjI=",
                "total": 3,
                "hasNextPage": true
              },
              "edges": [
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
                  "node": {
                    "id": "1",
                    "tasks": {
                      "pageInfo": {
                        "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
                        "endCursor": "YXJyYXljb25uZWN0aW9uOjM=",
                        "total": 3,
                        "hasNextPage": false
                      },
                      "edges": [
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
                          "node": {
                            "title": "Repellendus et tempora eos doloribus odit corporis a aspernatur."
                          }
                        },
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
                          "node": {
                            "title": "Consectetur aut nobis ut."
                          }
                        },
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjM=",
                          "node": {
                            "title": "Animi a necessitatibus dolores enim cupiditate."
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
                  "node": {
                    "id": "2",
                    "tasks": {
                      "pageInfo": {
                        "startCursor": "YXJyYXljb25uZWN0aW9uOjE=",
                        "endCursor": "YXJyYXljb25uZWN0aW9uOjM=",
                        "total": 3,
                        "hasNextPage": false
                      },
                      "edges": [
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjE=",
                          "node": {
                            "title": "Et autem vitae sed sapiente."
                          }
                        },
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjI=",
                          "node": {
                            "title": "Occaecati eos aut voluptatibus veritatis."
                          }
                        },
                        {
                          "cursor": "YXJyYXljb25uZWN0aW9uOjM=",
                          "node": {
                            "title": "Explicabo quia error fugit neque qui."
                          }
                        }
                      ]
                    }
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

from lighthouse.

vestervang avatar vestervang commented on July 19, 2024

Okay finally got around to create a repo with my code.

https://github.com/vestervang/lighthouse-test

I hope this helps find the issue because I sure can't.

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

@vestervang I see it! Might not be able to really dig in until this afternoon but I'll let you know as soon as I have a fix!

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

@vestervang looks like the count field requires snake_case... re-pull from master and let me know if that resolved the issue on your end!

from lighthouse.

vestervang avatar vestervang commented on July 19, 2024

That solved the problem! Thanks for the help and hard work.

from lighthouse.

chrissm79 avatar chrissm79 commented on July 19, 2024

Awesome, thanks for reporting the issue!!!

from lighthouse.

Related Issues (20)

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.