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
GraphQL Error Unknown argument slug
#2069
Comments
It's possible a node doesn't have a slug perhaps?
…On Sun, Sep 10, 2017, 7:17 AM Josh Weaver ***@***.***> wrote:
Hey everyone. Trying to wire up contentful to a blog using the advanced
starter. I've pulled out the filesystem plugins from the mix and am trying
to just get a sample post pulled over. However, I'm currently getting an
error GraphQL Error Unknown argument slug on starting develop server.
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
graphql(
`
{
allContentfulBlogPost(limit: 1000) {
edges {
node {
id
slug
}
}
}
}
`
)
.then(result => {
if (result.errors) {
reject(result.errors)
}
const postPage = path.resolve("src/templates/post.jsx");
_.each(result.data.allContentfulBlogPost.edges, edge => {
console.log(edge.node);
createPage({
path: `/post/${edge.node.slug}`,
component: postPage,
context: {
id: edge.node.id,
slug: edge.node.slug
},
})
})
})
.then(resolve)
})
}
I have context set to include "slug" which, if I understand correctly, is
where it becomes available to the actual post component graphQL query...
but it's throwing the error.
Here's some of my console output where this happens
Fetch Contentful data: 404.350ms
success source and transform nodes — 0.552 s
success building schema — 0.548 s
success createLayouts — 0.055 s
⠁ /xxxxxxx/src/templates/post.jsx
{ id: 'c7juaTIcg6cW2wAGKCQuios', slug: 'test-post' }
success createPages — 0.061 s
success createPagesStatefully — 0.023 s
GraphQL Error Unknown argument `slug`
file: /Users/joshuaweaver/Documents/JoyfulNoise/joyfulnoiseliving/src/templates/post.jsx
1 |
2 | query BlogPostBySlug($slug: String!) {
> 3 | allContentfulBlogPost(slug: { eq: $slug }) {
| ^
4 | title
5 | slug
...
I'm pretty new to GraphQL so i could be missing something obvious here.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2069>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEVh7fahni3VfI4tz_PphtJPctw2jV5ks5sg2LWgaJpZM4PSM2E>
.
|
Well, i only had one node/post in Contentful. Hmm.. I ended up changing the query while it was running from |
Oh right, yeah, that query wouldn't have worked. Make sure to try out your queries in GraphiQL before adding them to your components. "all" is for querying all nodes of a type. Without all is for querying a single item. |
Hey everyone. Trying to wire up contentful to a blog using the advanced starter. I've pulled out the filesystem plugins from the mix and am trying to just get a sample post pulled over. However, I'm currently getting an error
GraphQL Error Unknown argument slug
on starting develop server.I have context set to include "slug" which, if I understand correctly, is where it becomes available to the actual post component graphQL query... but it's throwing the error.
Here's some of my console output where this happens
I'm pretty new to GraphQL so i could be missing something obvious here. Anything out of the ordinary from what you can see here? Thanks for looking!
The text was updated successfully, but these errors were encountered: