【发布时间】:2018-12-27 16:33:28
【问题描述】:
我正在使用 Prisma、Apollo Client、GraphQL-yoga 开发一个简单的 React 应用程序。 在关注this tutorial about react-apollo-form 时,我遇到了这个问题。
./src/components/CreateEntry.js
Module not found: Can't resolve '../forms/ApplicationForm' in 'C:\Users\massi\Desktop\sandbox\erbar10\erbar10\src\components'
我的树
CreateEntry.js
import React, { Component } from "react";
import { withApollo } from "react-apollo";
import gql from "graphql-tag";
import { ApplicationForm } from "../forms/ApplicationForm";
const CREATE_DRAFT = gql`
mutation createDraft($name: String!) {
createDraft(name: $name, scientificName: $scientificName, file: $file) {
id
name
scientificName
}
}
`;
class CreateEntry extends Component {
render() {
return (
<ApplicationForm
title="Entry Form"
liveValidate={true}
config={{
mutation: {
name: "createDraft",
document: CREATE_DRAFT
}
}}
data={{}}
ui={{}}
/>
);
}
}
export default withApollo(CreateEntry);
ApplicationForm.ts
import * as React from "react";
import { configure } from "react-apollo-form";
import client from "../index";
const jsonSchema = require("./apollo-form-json-schema.json");
const ApplicationForm = configure<ApolloFormMutationNames>({
client: client as any,
jsonSchema
});
export default ApplicationForm;
我检查并检查了我的导入,但找不到解决方案。问题与 .ts 文件有关吗?我确信我会在一杯水中迷失自我。
更新: 还有一个问题: 在 ApplicationForm.ts ApolloFormMutationNames 上突出显示“找不到名称 ApolloFormMutationNames”。
mutations.d.ts
/* this file is generated, do not edit and keep it in tsconfig.rootDir scope! */
declare type ApolloFormMutationNames =
| "createDraft"
| "deleteEntry"
| "publish"
| "setToBeReviewed";
【问题讨论】:
标签: reactjs typescript import