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

⚡️ Accept array of string as valid input schema path. #134

Merged
merged 4 commits into from
Oct 4, 2021
Merged

⚡️ Accept array of string as valid input schema path. #134

merged 4 commits into from
Oct 4, 2021

Conversation

hsblhsn
Copy link
Contributor

@hsblhsn hsblhsn commented Oct 4, 2021

This PR adds a feature that accepts both string and array of string as valid input in schema key in config.

This feature is completely backward compatible. It does not deprecate or break the previous config file format.

Most of the code is sourced from https://github.com/99designs/gqlgen.

Closes #88

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.

Thanks, this look good to me!

The only thing that's needed before landing is to update docs/CHANGELOG.md, to add this new feature under ### New features:. There's also probably some documentation elsewhere in docs/ that needs to be updated to document the new yaml file format possibility.

generate/stringlist.go Show resolved Hide resolved
var schemaRaw []byte
schemaRaw, err = ioutil.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("unable to open schema: %w", err)
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 genqlient has its own errorf wrapper -- is it appropriate to use that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it appropriate to use that here?

You are right. Whole code should have one unified style. Pushed f471c95.

@hsblhsn hsblhsn requested a review from csilvers October 4, 2021 19:56
@hsblhsn
Copy link
Contributor Author

hsblhsn commented Oct 4, 2021

How does this sound to you?

# The filename with the GraphQL schema (in SDL format), relative to
# genqlient.yaml. This can also be a list of filenames.
# such as:
#  schema:
#  - user.graphql
#  - ./schema/*.graphql
#  - ./another_directory/**/*.graphqls
schema: schema.graphql

It would be more specific. WDYT?

@csilvers
Copy link
Member

csilvers commented Oct 4, 2021

How does this sound to you?

# The filename with the GraphQL schema (in SDL format), relative to
# genqlient.yaml. This can also be a list of filenames.
# such as:
#  schema:
#  - user.graphql
#  - ./schema/*.graphql
#  - ./another_directory/**/*.graphqls
schema: schema.graphql

It would be more specific. WDYT?

That looks great! It makes clear you can use glob patterns, 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.

Awesome! Thanks so much.

I don't know if I actually have the ability to merge this in, but hopefully someone else on this review does if I don't.

@csilvers csilvers merged commit 59b6df6 into Khan:main Oct 4, 2021
@dnerdy
Copy link
Contributor

dnerdy commented Oct 4, 2021

Hello @hsblhsn! Thanks for the contribution. Could you sign the Khan Academy Contributor License Agreement when you have a moment?

benjaminjkraft added a commit that referenced this pull request 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.

Test plan: make check
benjaminjkraft added a commit that referenced this pull request Oct 5, 2021
…137)

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
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.

Feature Request: Support multiple schema files
3 participants