Apollo Explorer 未反映源代码中的更改
Apollo Explorer not reflecting changes in source code
我一直在对我的源代码进行一些更改,但我无法让它们显示在 Apollo Explorer Sandbox 中。例如,我在源代码中向我的一个解析器添加了一些突变和一个额外的查询,但它们没有出现在 Apollo Sandbox 中。有什么想法吗?
import { Arg, Ctx, Int, Mutation, Query, Resolver } from "type-graphql";
import { Post } from "src/entities/Post";
import { MyContext } from "src/types";
import { idText } from "typescript";
@Resolver()
export class PostResolver {
@Query(() => [Post])
posts(@Ctx() { em }: MyContext): Promise<Post[]> {
return em.find(Post, {});
}
@Query(() => Post, { nullable: true })
post(@Arg("id", () => Int) id: number, @Ctx() { em }: MyContext): Promise<Post | null> {
return em.findOne(Post, { id });
}
@Mutation(() => Post)
async createPost(
@Arg("title") title: string,
@Ctx() { em }: MyContext
): Promise<Post> {
const post = em.create(Post, {title});
await em.persistAndFlush(post);
return post;
}
@Mutation(() => Post, {nullable: true})
async updatePost(
@Arg("id") id: number,
@Arg("title", () => String, { nullable: true }) title: string,
@Ctx() { em }: MyContext
): Promise<Post | null> {
const post = await em.findOne(Post, { id });
if (!post) {
return null;
}
if (typeof title !== 'undefined') {
post.title = title;
await em.persistAndFlush(post);
}
return post;
}
}
我想通了。这只是 dist 文件夹中的 javascript 代码未使用打字稿代码更新的问题。使用 yarn watch 更新并修复了问题。
我一直在对我的源代码进行一些更改,但我无法让它们显示在 Apollo Explorer Sandbox 中。例如,我在源代码中向我的一个解析器添加了一些突变和一个额外的查询,但它们没有出现在 Apollo Sandbox 中。有什么想法吗?
import { Arg, Ctx, Int, Mutation, Query, Resolver } from "type-graphql";
import { Post } from "src/entities/Post";
import { MyContext } from "src/types";
import { idText } from "typescript";
@Resolver()
export class PostResolver {
@Query(() => [Post])
posts(@Ctx() { em }: MyContext): Promise<Post[]> {
return em.find(Post, {});
}
@Query(() => Post, { nullable: true })
post(@Arg("id", () => Int) id: number, @Ctx() { em }: MyContext): Promise<Post | null> {
return em.findOne(Post, { id });
}
@Mutation(() => Post)
async createPost(
@Arg("title") title: string,
@Ctx() { em }: MyContext
): Promise<Post> {
const post = em.create(Post, {title});
await em.persistAndFlush(post);
return post;
}
@Mutation(() => Post, {nullable: true})
async updatePost(
@Arg("id") id: number,
@Arg("title", () => String, { nullable: true }) title: string,
@Ctx() { em }: MyContext
): Promise<Post | null> {
const post = await em.findOne(Post, { id });
if (!post) {
return null;
}
if (typeof title !== 'undefined') {
post.title = title;
await em.persistAndFlush(post);
}
return post;
}
}
我想通了。这只是 dist 文件夹中的 javascript 代码未使用打字稿代码更新的问题。使用 yarn watch 更新并修复了问题。