Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Throw error when no schema nor operation files are found #2618

Merged
merged 4 commits into from
Oct 28, 2022

Conversation

calvincestari
Copy link
Member

Closes #2567

When a schema file could not be found graphql-js would emit errors but they were not indicative of the underlying problem. I've added validation to ensure that at least one match of the schema/operation search paths is found otherwise an error is thrown.

@netlify
Copy link

netlify bot commented Oct 27, 2022

Deploy Preview for apollo-ios-docs canceled.

Name Link
🔨 Latest commit c0017d3
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docs/deploys/635c476b23d0fd0009ef2345

@@ -56,12 +62,14 @@ public class ApolloCodegen {
rootURL: rootURL
)

try validate(config: configContext)
Copy link
Member Author

@calvincestari calvincestari Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've separated these two validate calls because the first one includes path syntax validation and should be done before compilation of the schema + operations. The second validation (line 72) ensures no schema name conflict.

I don't like that they're now separate, some ideas to improve:

  • rename the second one from validate to something else
  • move the schema name logic somewhere else

@@ -191,7 +191,7 @@ public struct Glob {
globfree(&globT)
}

CodegenLogger.log("Matching \(pattern)", logLevel: .debug)
CodegenLogger.log("Evaluating \(pattern)", logLevel: .debug)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching was too close to Matched. Evaluating is more indicative of what the logic is actually doing.

@calvincestari calvincestari merged commit 565a95d into main Oct 28, 2022
@calvincestari calvincestari deleted the fix/codegen-error-responses branch October 28, 2022 21:26
@calvincestari calvincestari mentioned this pull request Nov 1, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return error if no matches to schema or operation search paths
1 participant