You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行relay-compiler时遇GraphQL类型错误及Watchman路径问题求解决方案

Fixing Relay Compiler Issues: Watchman Warning + "Expected undefined to be a GraphQL leaf type" Error

Let’s tackle your problems one by one—first the Watchman warning (which is just a heads-up, not the root cause of your failure), then the critical type error that’s causing the exit code 100.

1. Resolving the Watchman Warning

That Watchman message is only a warning, not the reason your command failed. Here’s how to handle it:

  • Option 1: Install Watchman: If you want to use Relay’s file-watching feature (for auto-recompiling when files change), install Watchman following the official installation steps for your OS.
  • Option 2: Disable Watchman checks: If you don’t need watching right now, add the --no-watch flag to your Relay command to skip Watchman entirely:
    relay-compiler --src ./src/client --schema schema.graphql --no-watch
    

2. Fixing the "Expected undefined to be a GraphQL leaf type" Error

This is the critical issue that’s making your command fail with exit code 100. It means your schema.graphql file contains a field with an invalid undefined type—GraphQL doesn’t recognize undefined as a valid leaf type (like String, Int, Boolean, ID, or custom scalars).

Here’s how to debug and fix it:

  • Step 1: Audit your schema file: Open schema.graphql and search for any occurrence of undefined. You’ll likely find a line like:
    someField: undefined
    
    This is invalid—replace undefined with a valid GraphQL leaf type (e.g., String, Int, or a custom scalar you’ve defined).
  • Step 2: Verify the source schema: The undefined type probably came from your GraphQL server. Check if your server’s schema has a field with an unassigned or incorrectly resolved type. For example, maybe a resolver is returning undefined instead of a valid type, or the schema definition itself is missing a type declaration.
  • Step 3: Re-export the schema correctly: If get-graphql-schema is causing the issue, try an alternative tool to export your schema. For example, use graphql-cli (install it first with npm install -g graphql-cli) and run:
    graphql get-schema --endpoint http://localhost/api/office --output schema.graphql
    
    Or copy the schema directly from your server’s GraphQL Playground (if available) to ensure accuracy.
  • Step 4: Check for custom scalars: If you’re using custom scalars in your schema, make sure they’re properly defined in schema.graphql (e.g., scalar DateTime) and that Relay knows how to handle them (you may need to add scalar handling in your Relay configuration).

Once you’ve fixed the invalid undefined type in your schema, re-run the Relay compiler command—it should work without the exit code 100 error.

内容的提问来源于stack exchange,提问作者dprosper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:44:28