遵循Graphcool TypeScript教程时遇‘Project not found: my-app@dev’错误求助
Hey there, let's break down why you're hitting this error even after following the tutorial closely.
First, let's look at the clues you provided:
- The error says
Project not found: 'my-app@dev' - Your
graphcool infooutput shows your service is namedmy-app dev(with a space) and runs on thelocalcluster, with endpointhttp://localhost:60000/my-app/dev
What's causing the issue?
The problem comes down to how Graphcool identifies projects. The expected format for a project ID is [service-name]@[cluster-name]. In your case:
- Your service name has a space (
my-app dev) which can cause parsing issues - The error is looking for
my-app@dev, but your cluster is actuallylocal, notdev
Step-by-step fixes
1. Rename your service to remove spaces (and align with expected format)
Spaces in service names can throw off Graphcool's project ID matching. Let's rename it to something clean:
graphcool rename my-app-dev --cluster local
2. Update your endpoint in the GraphQLServer code
After renaming, run graphcool info again—your endpoint should now be http://localhost:60000/my-app-dev/dev. Update your code to match:
const server = new GraphQLServer({ typeDefs: './src/schema.graphql', resolvers, context: req => ({ ...req, db: new Graphcool({ endpoint: 'http://localhost:60000/my-app-dev/dev', secret: 'mysecret123', }), }), })
3. (Optional) Explicitly set the project ID
If you still run into issues, some versions of the Graphcool SDK require explicitly passing the projectId parameter. Use the format [new-service-name]@local:
db: new Graphcool({ endpoint: 'http://localhost:60000/my-app-dev/dev', secret: 'mysecret123', projectId: 'my-app-dev@local', }),
4. Restart your local Graphcool service
Sometimes changes don't take effect until you restart the service:
graphcool stop graphcool start
Why this works
The tutorial uses my-app@dev assuming a dev cluster, but your local setup uses the local cluster. Plus, the space in your original service name made it impossible for Graphcool to correctly map to your project. By renaming and aligning the identifiers, you'll fix the mismatch that's causing the error.
内容的提问来源于stack exchange,提问作者Niks

