HoudiniGraphql / houdini

The disappearing GraphQL framework
http://www.houdinigraphql.com
MIT License
913 stars 99 forks source link

Development server crashes if schema gets modified #1377

Closed ewen-lbh closed 2 weeks ago

ewen-lbh commented 1 month ago

Describe the bug

So basically I'm developing the API server alongside the frontend, and often when I make changes on the API server, while it re-generates the schema it seems like the schema is an empty file during a small period of time.

Unfortunately it's enough for Houdini to pick up on, try to reload and crash with a syntax error.

I think that schema syntax errors should cause the vite server to wait for changes before trying again, instead of crashing, because I have to restart vite everytime:

/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/error/syntaxError.js:15
  return new _GraphQLError.GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
         ^

GraphQLError [Object]: Syntax Error: Unexpected <EOF>.
    at syntaxError (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/error/syntaxError.js:15:10)
    at Parser.unexpected (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/language/parser.js:1471:41)
    at Parser.parseDefinition (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/language/parser.js:161:16)
    at Parser.many (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/language/parser.js:1523:26)
    at Parser.parseDocument (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/language/parser.js:115:25)
    at parse (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/language/parser.js:31:17)
    at Module.buildSchema (/home/uwun/projects.local/churros/node_modules/houdini/node_modules/graphql/utilities/buildASTSchema.js:106:36)
    at loadSchemaFile (file:///home/uwun/projects.local/churros/node_modules/houdini/build/vite-esm/index.js:69863:21)
    at async getConfig (file:///home/uwun/projects.local/churros/node_modules/houdini/build/vite-esm/index.js:69731:26)
    at async Object.watchFile (file:///home/uwun/projects.local/churros/node_modules/houdini/build/vite-esm/index.js:79315:15) {
  locations: [ { line: 1, column: 1 } ]
}

Node.js v20.6.1

unfortunately, providing a repro is quite complicated, i can try if it's absolutely necessary

i can also try to implement this, i just need some pointers on where the parsing gets done (and how it hooks into vite)

Reproduction

No response

AlecAivazis commented 4 weeks ago

Huh strange. I have a few projects where the API is an external process that I'm developing against and the schema changes without any issues. I think we'll probably need a reproduction to hunt this down

AlecAivazis commented 2 weeks ago

Hey @ewen-lbh im going to close this since its gone abit stale but let me know if you have some time to dig into it 👍