React graphql 给出错误 解析错误:类型强制转换表达式应用括号括起来


query BlogPostByPath($path: String!){
markdownRemark(
frontmatter : {
path : {eq:$path}
}
){
html
frontmatter{
path
title
}
}
}

这是我的代码
,错误是

19:19  error  Parsing error: The type cast expression is expected to
be wrapped with parenthesis
> 
>   17 |   query BlogPostByPath($path: String!){      
>   18 |                 markdownRemark(
> > 19 |       frontmatter : {
>   20 |                   ^    path : {eq:$path}   

我是 graphql 的新手。我正在向 https://www.youtube.com/watch?v=VxVKMJThh04&list=PLLnpHn493BHHfoINKLELxDch3uJlSapxg&index=5
学习 请提供任何帮助...

我的错误如上面的代码是

import React from 'react';
import Helmet from 'react-helmet';
export default function Template({data}) {
const {markdownRemark: post} = data;
// const post = data.markdownRemark;
return (
<div>
<h1>{post.frontmatter.title}</h1>
<div dangerouslySetInnerHTML={{__html: post.html}} > // error was here 
</div>
)
}
export const postQuery = graphql`
query BlogPostByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path} }) {
html
frontmatter {
path
title
}
}
}
`

错误是因为上面的div 选项卡没有关闭。

最新更新