我使用创建-反应-应用程序和反应-应用程序重新连线,以自定义我的配置。这是我的config-overrides.js:
const { override, fixBabelImports, addLessLoader } = require('customize-cra')
const rewireInlineImportGraphqlAst = require('react-app-rewire-inline-import-graphql-ast')
module.exports = override(
rewireInlineImportGraphqlAst,
fixBabelImports('antd', {
libraryDirectory: 'es',
style: true
}),
fixBabelImports('ant-design-pro', {
libraryDirectory: 'lib',
style: true,
camel2DashComponentName: false
}),
fixBabelImports('lodash', {
libraryDirectory: '',
camel2DashComponentName: false
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: {
'@primary-color': '#308AC9',
'@font-size-lg': '15px',
'@menu-inline-toplevel-item-height': '34px',
'@menu-item-height': '34px'
}
})
)react-app-rewire-inline-import-graphql-ast用于在构建期间解析graphql文件,因此我可以使用阿波罗导入这样的graphql:
import React from 'react'
import editUserMutation from '../graphql/editUser.graphql'
const Editor = () => (
<Mutation mutation={editUserMutation}>
{mutate => ...}
</Mutation>
)这是我的graphql文件:
mutation($email: String!, $password: String!, $name: String!, $job: String!, $website: String!, $bio: String!, $avatar: String) {
editUser(email: $email, password: $password, name: $name, job: $job, website: $website, bio: $bio, avatar: $avatar) {
id
}
}现在,问题是:我第一次在我的graphql文件中犯了一个错误,写了_id而不是id,所以GraphQL抱怨道
无法查询“用户”类型上的字段"_id“
但经过修正后,GraphQL仍然抱怨_id。通过记录导入的editUserMutation AST,我发现旧的有缺陷的版本仍然被缓存和使用。
我尝试了很多事情:-在整个项目上重新启动yarn start -重命名然后重命名我的graphql文件-清理我的浏览器缓存
什么都帮不上忙。
这里有什么问题?谢谢。
编辑:通过删除node_modules文件夹并重新安装依赖项,解决了这个问题。所以在那个文件夹里可能有某种非常持久的缓存,有人知道在哪里吗?
发布于 2019-04-21 16:33:14
从基础插件的文档中获取
每次修改GraphQL文件时,为了使更改生效,必须清除node_modules/..cache/babel-loader文件夹。我建议将相关脚本放在package.json中的前面,并在更改GraphQL文件时重新运行该脚本:
{
"scripts": {
"start": "rm -rf ./node_modules/.cache/babel-loader && node index.js"
}
}https://stackoverflow.com/questions/55783964
复制相似问题