我正在从同一项目的有效实现中构建新的createRefetchContainer()
,但是在运行yarn relay
时遇到此错误:
ERROR:
GraphQLParser: Unknown field `usersByName` on type `Viewer`.
Source: document `AutocompleteUsersContainer_UsersRefetchQuery` file:
`client/components/Autocomplete/Users/AutocompleteUsersContainer.js`.
错误的继电器功能:
export default createRefetchContainer(
AutocompleteUsers,
graphql`
fragment AutocompleteUsersContainer_viewer on Viewer
@argumentDefinitions(name: { type: "String", defaultValue: "" }) {
usersByName(name: $name)
}
`,
graphql`
query AutocompleteUsersContainer_UsersRefetchQuery(
$name: String!
) {
viewer {
usersByName(name: $name){
id
}
}
}
`
);
有效的实现方式
export default createRefetchContainer(
AutocompleteLocations,
graphql`
fragment AutocompleteLocationsContainer_viewer on Viewer
@argumentDefinitions(searchValue: { type: "String", defaultValue: "" }) {
locations(searchValue: $searchValue)
}
`,
graphql`
query AutocompleteLocationsContainer_LocationsRefetchQuery(
$searchValue: String!
) {
viewer {
locations(searchValue: $searchValue)
}
}
`
);
下面的usersByName
查询直接在graphql中返回结果,这就是为什么我不确定relay
为什么说Unknown field 'usersByname'
的原因:
query getViewer{
viewer {
usersByName(
name: "Test Name"
) {
id
}
}
}
答案 0 :(得分:1)
通过在val path = File(".").toAbsolute //D:\app\idea2016\bin\
System.getProperty("user.dir") //D:\app\idea2016\bin\
之前运行yarn schema
来解决