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

Align support for multiple operation-files and multiple schema-files #137

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

benjaminjkraft
Copy link
Collaborator

@benjaminjkraft benjaminjkraft commented Oct 5, 2021

Multiple schema-files are now supported as of #134, but the support was
a bit different from how we did multiple operation-files. Before anyone
starts to depend on the ways the syntaxes differ, let's just make them
the same. Since it's easy, I also added support for having just a
single operations-file.

I also realized while writing this that the type-change is technically
breaking (if you call from Go), so documented it as such. I think
this is unlikely to affect many people.

Test plan: make check

Multiple schema-files are now supported as of #134, but the support was
a bit different from how we did multiple operation-files.  Before anyone
starts to depend on the ways the syntaxes differ, let's just make them
the same.  Since it's easy, I also added support for having just a
single operations-file.

Test plan: make check
Copy link
Member

@csilvers csilvers left a comment

Choose a reason for hiding this comment

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

It looks like you don't support ** anymore? (Or does Glob do it by default these days?) That's fine, I think, but you'll probably want to update the doc example that has one.

(I'd be ok with switching to git-style extended globs, but I'd want to
be consistent, so for now let's keep it as-is.)
}

for _, m := range matches {
if schemas.Has(m) {
Copy link
Member

Choose a reason for hiding this comment

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

You can probably get rid of the Has function too.

Copy link
Member

@csilvers csilvers left a comment

Choose a reason for hiding this comment

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

Great! You may want to cc the original patch author so they know of the semantic change around **.

@benjaminjkraft
Copy link
Collaborator Author

cc @hsblhsn if you wanted to take a look! If it's an issue we could move to using the fancier globbing for both.

Copy link
Contributor

@hsblhsn hsblhsn left a comment

Choose a reason for hiding this comment

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

Just my thoughts. Don't make it hard to debug.

Comment on lines -26 to +36
filename, _ := graphqlError.Extensions["file"].(string)
return nil, errorf(nil, "invalid schema file %v: %v", filename, graphqlError)
return nil, errorf(nil, "invalid schema: %v", graphqlError)
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing file name from error message will make it really hard to find issues in schema or operation files. Since we still do not have strong IDE support for graphql SDL files.

WDYT?

testdata/errors/InvalidSchema.schema.graphql:4: invalid schema file testdata/errors/InvalidSchema.schema.graphql: Expected :, found }
testdata/errors/InvalidSchema.schema.graphql:4: invalid schema: Expected :, found }
Copy link
Contributor

Choose a reason for hiding this comment

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

Finding the exact issue will be tough just by seeing the new error message. Previous message was better IMO.

Copy link
Member

Choose a reason for hiding this comment

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

I think the filename is still there, just in a different place:

 testdata/errors/InvalidSchema.schema.graphql:4: invalid schema: Expected :, found } 
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Copy link
Contributor

Choose a reason for hiding this comment

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

Opps, sorry I missed it. LGTM now!

@benjaminjkraft benjaminjkraft merged commit 2201928 into main Oct 5, 2021
@benjaminjkraft benjaminjkraft deleted the benkraft.align-globs branch October 5, 2021 19:52
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.

3 participants