Giter VIP home page Giter VIP logo

build-a-graphql-server's People

Contributors

joaquinsiabra 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

Watchers

 avatar  avatar  avatar

build-a-graphql-server's Issues

Query videos by it's IDs

Hey @joshblack

I was following the egghead tutorial: https://egghead.io/courses/build-a-graphql-server to build a GraphQL server. I've noticed that querying videos by it's IDs doesn't currently work and was wondering if you'd know what's the issue? I'd tried fixing it but couldn't figure out the right approach.

Querying nodes by it's ID works correctly.

Looking up all videos like this:

query Videos {
  videos {
    edges {
      node {
        id
        title
      }
    }
  }
}

gives us the following result

{
  "data": {
    "videos": {
      "edges": [
        {
          "node": {
            "id": "VmlkZW86YQ==",
            "title": "Create a GraphQL Schema"
          }
        },
        {
          "node": {
            "id": "VmlkZW86Yg==",
            "title": "Ember.js CLI"
          }
        }
      ]
    }
  }
}

If we query nodes for the following ID: VmlkZW86Yg==

query NodeById {
  node(id: "VmlkZW86YQ==") {
    ... on Video {
      title
    }
  }
}

everything seems OK and we get

{
  "data": {
    "node": {
      "title": "Create a GraphQL Schema"
    }
  }
}

but trying the same for videos doesn't return the correct video

query VideoById {
  video(id: "VmlkZW86YQ==") {
    title
  }
}

returns

{
  "data": {
    "video": null
  }
}

I believe it's got something to do with translating global ID, but I can't figure it out.

ps: Thanks for such a great tutorial, me and my team have really enjoyed it!

Why [video] instead of just video?

Hi Josh,

Loved your course on egghead and found it incredibly helpful in setting up my first graphql server. I found most of it to be very well explained, but I did find myself giving a half-head-tilt trying to understand why in "Use Arguments in a GraphQL Query" the video variable had to be wrapped in square brackets [] to work.

image

At first I thought it was because it was returning an array, so I thought this might also work...

const getVideoById = (id) => new Promise( resolve => {
    const video = videos.filter( video => {
        return video.id === id;
    });
    resolve([video])
});

But that's obviously not right because that throws an error. Would you mind helping me understand? Thanks!

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.