简体   繁体   English

中继编译器语法错误:预期名称,找到“}”

[英]Relay Compiler Syntax Error: Expected Name, found "}"

could not figure out why my query has syntax errors for hours.无法弄清楚为什么我的查询有几个小时的语法错误。 I copy and paste the query to graphiql and it works fine.我将查询复制并粘贴到 graphiql,它工作正常。 When I ran relay compiler against my js, it threw this error.当我对我的 js 运行中继编译器时,它抛出了这个错误。 Does anyone have the same issue?有没有人有同样的问题?

The weird thing is if I remove the "query HomeQuery", it gave different error to complain about operation name..奇怪的是,如果我删除“查询 HomeQuery”,它会给出不同的错误来抱怨操作名称。

my code我的代码

import {graphql} from "react-relay";

const query = graphql`
    query HomeQuery {
        tasks {
            id
        }
    }
`;

my package.json我的 package.json

...
    "relay": "relay-compiler --schema ../resources/schema.graphql --src ./pages/test"
...

I ran npm run-script relay我跑了 npm run-script relay

the log
 relay-compiler --schema ../resources/schema.graphql --src ./pages/test


Writing js
ERROR:
Syntax Error: Expected Name, found "}".
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! my-app2@0.1.0 relay: `relay-compiler --schema ../resources/schema.graphql --src ./pages/test`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the my-app2@0.1.0 relay script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

turnout it is just your schema cannot have empty结果只是您的架构不能为空

type Mutation {类型突变{

} }

after I revmoed the empty type Mutation, everything is working....在我修改了空类型 Mutation 之后,一切正常....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM