Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Conversation

@jamesdh
Copy link
Contributor

@jamesdh jamesdh commented Nov 10, 2020

Fixes #53. Sorry for taking so long to submit this!

A core part of the GraphQL spec is the ability for fields to take arguments. This PR adds the ability to define custom fields on an object which in turn take arguments. It does not contain the ability to define arguments on existing fields.

I may have been overzealous in upgrading some of the gradle bits. Feel free to let me know if you'd like me to resubmit without those changes.

This PR does not yet contain any related documentation changes, hence the draft status. Wanted to get a little feedback before putting any time into them.

.deprecate(prop.deprecationReason)
.description(prop.description)

if(prop instanceof CustomGraphQLProperty) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This felt a little gross to me, but no other place stood out as a better alternative for actually building the property-level arguments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. You should use something like:

        if(prop instanceof Arguable) {
            List<GraphQLArgument> arguments = prop.getArguments(typeManager, mapping)
            if (!arguments.isEmpty()) {
                field.arguments(arguments)
            }
        }

* @return The operation in order to chain method calls
*/
T argument(String name, Class type, @DelegatesTo(value = SimpleArgument, strategy = Closure.DELEGATE_ONLY) Closure closure = null) {
T argument(String name, Class<?> type, @DelegatesTo(value = SimpleArgument, strategy = Closure.DELEGATE_ONLY) Closure closure = null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar, in that when the implementing GORM entity used @GrailsCompileStatic, this would result in a static compilation error without the generic wildcard.

Copy link
Contributor

@jameskleeh jameskleeh left a comment

Choose a reason for hiding this comment

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

Overall this PR is pretty good. I think if we're going to introduce breaking changes by moving the argument classes, and modifying this method signature (https://github.com/grails/gorm-graphql/pull/56/files#diff-65191fd62016a5999609edc95174e48c4937c21dfe6bae9773874e3efbea5169R55), we should also do the upgrades to Groovy 3, etc and include it in Grails 4.1

Let me know if you would prefer to proceed without breaking changes and include this in an earlier release

.deprecate(prop.deprecationReason)
.description(prop.description)

if(prop instanceof CustomGraphQLProperty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. You should use something like:

        if(prop instanceof Arguable) {
            List<GraphQLArgument> arguments = prop.getArguments(typeManager, mapping)
            if (!arguments.isEmpty()) {
                field.arguments(arguments)
            }
        }

@jamesdh
Copy link
Contributor Author

jamesdh commented Nov 23, 2020

I'm fine with including it in Grails 4.1, although I'm a little unclear how it's a breaking change. None of the original functionality of the DSL is altered from what I can see.

I'll go ahead and write up some doc changes to go with it.

- Pushed them up a level to help imply they can be used for both operations and fields
- Added a bit to the examples to emphasize usage
@jamesdh
Copy link
Contributor Author

jamesdh commented Dec 9, 2020

@jameskleeh can you clarify what you meant by breaking changes? From what I can tell, nothing exposed in the public API/DSL has been altered, only additions.

For the sake of just taking baby steps, I'd rather avoid doing the upgrade to Groovy 3/Grails 4.1 in this PR. I'd be happy to do so in another though.

@jamesdh jamesdh marked this pull request as ready for review December 9, 2020 17:50
@jamesdh jamesdh requested a review from jameskleeh December 9, 2020 17:51
@jameskleeh
Copy link
Contributor

And build field arguments as seperate method to avoid any possible breakages
@jamesdh
Copy link
Contributor Author

jamesdh commented Dec 9, 2020

@jameskleeh this should be good now. Feel free to take another look!

@jamesdh
Copy link
Contributor Author

jamesdh commented Jan 13, 2021

@jeffbrown @jameskleeh @puneetbehl I understand you're all fairly focused on Micronaut these days and that's completely fair. But would it be possible to promote some additional people to this repo to move things along? There are lots of things that could be improved and I'd be happy to contribute some of my own time to do so, but at this point it's starting to feel all for naught.

@jameskleeh
Copy link
Contributor

@jamesdh Reviewing these PRs and creating a release is on my list of things to do. I assure you it is not all for naught

@jameskleeh jameskleeh merged commit 5149504 into grails:master Jan 13, 2021
@jamesdh
Copy link
Contributor Author

jamesdh commented Jan 13, 2021

Thanks for the update and the review @jameskleeh!

anatoliinzrnk added a commit to anatoliinzrnk/graphql-gorm that referenced this pull request Sep 10, 2024
matvieievserhii1 added a commit to matvieievserhii1/gorm-graphql that referenced this pull request Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No means for defining field arguments

2 participants