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

Support multiple setting sets per file #1156

Merged
merged 5 commits into from
Nov 24, 2021

Conversation

kubukoz
Copy link
Contributor

@kubukoz kubukoz commented Nov 19, 2021

This would be useful in situations where you want to generate both a server and a client from a single schema file, with potentially different settings.

Update: Added some more changes:

  • separated the scripted tests so there's one for the direct calibanGenClient calls and one for the setting-based generation
  • added scripted test for multiple set of settings per file
  • mentioned the usage in the docs
  • mentioned how to cherry-pick schemas for generation

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

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

Looks good! Would be nice to test it with scripted tests.

@kubukoz kubukoz marked this pull request as draft November 19, 2021 23:46
@kubukoz kubukoz force-pushed the multiple-outputs-per-file branch from ebf6845 to e5a6f46 Compare November 22, 2021 21:02
calibanSetting(file("src/main/graphql/schema.graphql"))( // Explicitly constrain to disambiguate
cs =>
cs.clientName("Client")
calibanSetting(file("src/main/graphql/schema.graphql"))( // Explicitly constrain to disambiguate
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh I don't get what this "constrains", is that comment up to date?

Copy link
Contributor

Choose a reason for hiding this comment

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

Certainly not the most helpful comment, as I don't understand what needed to be disambiguated here -- perhaps back when it was possible (or intended) to star-glob multiple files? I could see trying to disambiguate between the few .graphql test specifications we had at that time.

@kubukoz
Copy link
Contributor Author

kubukoz commented Nov 22, 2021

@ghostdogpr updated with a test and some other changes (see note in PR description) :)

cc @guizmaii I'd appreciate some eyes on this

@kubukoz kubukoz marked this pull request as ready for review November 22, 2021 21:08
Copy link
Contributor

@blast-hardcheese blast-hardcheese left a comment

Choose a reason for hiding this comment

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

👍 from me, good addition.

calibanSetting(file("src/main/graphql/schema.graphql"))( // Explicitly constrain to disambiguate
cs =>
cs.clientName("Client")
calibanSetting(file("src/main/graphql/schema.graphql"))( // Explicitly constrain to disambiguate
Copy link
Contributor

Choose a reason for hiding this comment

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

Certainly not the most helpful comment, as I don't understand what needed to be disambiguated here -- perhaps back when it was possible (or intended) to star-glob multiple files? I could see trying to disambiguate between the few .graphql test specifications we had at that time.

)
val matchingSettingSets = fileSettings.collect {
case needle if source.toPath.endsWith(needle.file.toPath) => needle.settings
}.map(defaults.combine(_))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the intended change in this PR, from what I can tell. I was foldLeft-ing in the beginning to permit tiered configuration, but that was before the cs pattern was discovered. I don't think it's useful to accumulate anymore, if the previous implementation was desired, it is possible to define a generic CalibanSettings => CalibanSettings and apply that before you chain the rest of your config.

Compile / caliban / calibanSources := file("caliban")
```

If you want to only include certain files in a directory, you can override that as well with an explicit `caliban / sources` entry:
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't actually true, since calibanSources is a File, not a List[File] -- the comment doesn't scale and will trip up users

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, hopefully it's correct now

@ghostdogpr
Copy link
Owner

LGTM, I will merge!

@ghostdogpr ghostdogpr merged commit cc59d4a into ghostdogpr:master Nov 24, 2021
Fluxx pushed a commit to Fluxx/caliban that referenced this pull request Jan 24, 2022
Fluxx pushed a commit to Fluxx/caliban that referenced this pull request Jan 27, 2022
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.

4 participants