Variable "$id" of type "ID!"
See original GitHub issueHave been able to get this plugin to work for a blog index, but am having trouble with the instructions for a single post. After several unsuccessful tries working with my existing single-post template, I decided to experiment and replace it with just the code from the example:
import React from "react"
import { graphql } from "gatsby"
export const pageQuery = graphql`
query($id: ID!, $previousPageId: ID!, $nextPageId: ID!) {
post: markdownRemark(id: { eq: $id }) {
html
frontmatter {
title
}
}
}
`;
const BlogPost = props => {
const { pageContext, data } = props;
const { previousPagePath, nextPagePath, previousPageItem, nextPageItem } = pageContext;
const { post } = data;
return (
<div>
<h1>{post.frontmatter.title}</h1>
<div dangerouslySetInnerHTML={{ __html: post.html }} />
<div>
{previousPagePath ? (
<Link to={pageContext.previousPagePath}>
{previousPageItem.frontmatter.title}
</Link>
) : null}
{nextPagePath ? (
<Link to={pageContext.nextPagePath}>
{nextPageItem.frontmatter.title}
</Link>
) : null}
</div>
</div>
);
}
export default BlogPost
. . . but when I did, I get a failure to compile and this error message:
GraphQL Error Variable "$id" of type "ID!" used in position expecting type "String".
Is there something else I should import
? Will greatly appreciate any help anyone’s willing to offer.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
"Variable \"$id\" of required type \"ID!\" was not provided."
I am trying to query by passing the variable id in the query variable window. This results in an error "Variable \"$id\" of...
Read more >Query collection by id Variable $id of type ID! was provided ...
Hi I want to get the products from a specific collection but I am getting following error bundle.esm.js?74ca:63 Uncaught (in promise) Error: ...
Read more >Invalid value for type ID, cannot be converted to AST - Help
If I query a user with with an id as the argument directly from service-users (localhost:5001/) in the sandbox everything works fine. query...
Read more >Vue apollo error: "Variable "$id" of required type "ID!" was not ...
Hi,. I've written apollo queries and mutations in Vue before but I'm running into an error with the following block of code:
Read more >vscode-apollo-relay/RelayVariablesInAllowedPosition-test.ts ...
objectContaining({ message: 'Variable "$id" of type "ID" used in position expecting type "ID!".' }) ) }) it("Allows valid fragment", () => {.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is your code copied from the examples folder? Just merged #23 which updates the examples, they had the wrong API. Maybe that’s the issue?
@brycewray The error suggests that the type of
markdownRemark
’seq
field should be astring
and not anID
. What do you see in the/___graphql
interface if you look at that field in the docs? Maybe Gatsby has changed the field type…