build-a-graphql-server's Issues
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.
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!
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!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.