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

Added FieldDef<'Val, 'Res> to support resolver changing middlewares #446

Closed
wants to merge 1 commit into from

Conversation

xperiandri
Copy link
Collaborator

In order to call Define.Field<'Val>(....).WithAuthorizationPolicy("policy") I need to know not only 'Res which is an object on which FieldDef<'Res> is defined but also a 'Val which is a field type.
However when I introduced FieldDef<'Val, 'Res> F# cannot determine the override between Define.Object that gets a list of field and a labmda that return a list of fields. So I had to rename Define.Object overrie to Define.ObjectRec and Define.Interface override to Define.ObjectRec.
I have not renamed Define.InputObject as it accepts a parameter of list of another interface

@GBirkel
Copy link
Contributor

GBirkel commented Oct 17, 2023

I'm afraid this one may be beyond my skill to review. I'm not sure what the long-term consequences of changing Object to ObjectRec would be.

@xperiandri
Copy link
Collaborator Author

Anyway we do breaking changes in v2.0
So the main difference is that you need to call Define.ObjectRec to define recursive GraphQL type definitions.
Also there is a question if need to rename Define.InputObject override to Define.InputObjectRec to be consistent or leave it as is to be simple?

@xperiandri xperiandri force-pushed the support-resolver-changing-middlewares branch from 1f20932 to 210fddb Compare October 17, 2023 23:00
Copy link
Collaborator

@valbers valbers left a comment

Choose a reason for hiding this comment

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

I get it.
In any case, I find it a good idea to generally avoid method overloads as F# doesn't support function overloads (although class members may have overloads, just like in our current situation -- which is causing the problem that you're trying to fix), and therefore not having overloads feels more like "the F# way", so I welcome this change already on this level, even if the offending overload were not causing any problems yet.

However, I'm not sure if I agree with the new name. ObjectRec is effectively not by definition recursive, but it can be used for a recursive definition.
That, which ObjectRec actually is, is an Object which takes a function for defining the fields instead of a concrete list of fields.

So, following the nomenclature of the F# core lib, I'd prefer for it to be named something like the defaultWith function of the Option module.

In that case, that could be ObjectHavingFieldsWith (instead of ObjectRec).
What do you think?

src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs Outdated Show resolved Hide resolved
src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs Outdated Show resolved Hide resolved
Base automatically changed from remove-unused-exceptions-bag to dev October 19, 2023 15:25
@xperiandri xperiandri force-pushed the support-resolver-changing-middlewares branch 3 times, most recently from 889f71d to be3c173 Compare October 20, 2023 23:15
Copy link
Contributor

@GBirkel GBirkel left a comment

Choose a reason for hiding this comment

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

Have the changes requested by valbers been addressed?

@xperiandri
Copy link
Collaborator Author

@njlr give your opinion, please

@xperiandri xperiandri force-pushed the support-resolver-changing-middlewares branch from c73ab43 to 86ac430 Compare September 1, 2024 13:23
@xperiandri xperiandri force-pushed the support-resolver-changing-middlewares branch 3 times, most recently from c590728 to e0841dc Compare September 1, 2024 15:39
@valbers
Copy link
Collaborator

valbers commented Sep 1, 2024

@xperiandri could you please do less force-pushes with commit amendments? It makes it hard to follow what you actually changed with each commit amendment. I mean: once in a while it's ok, but I see this now very often.

@@ -800,15 +801,14 @@ module SchemaDefinitions =
/// <param name="description">Optional field description. Usefull for generating documentation.</param>
/// <param name="args">Optional list of arguments used to parametrize field resolution.</param>
/// <param name="deprecationReason">If set, marks current field as deprecated.</param>
static member AutoField(name : string, typedef : #OutputDef<'Res>, ?description: string, ?args: InputFieldDef list, ?deprecationReason: string) : FieldDef<'Val> =
static member AutoField(name : string, typedef : OutputDef<'Res>, ?description: string, ?args: InputFieldDef list, ?deprecationReason: string) : FieldDef<'Val, 'Res> =
Copy link
Member

Choose a reason for hiding this comment

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

Was the # removed on purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I either got a warning or error because of this

Copy link
Collaborator

@valbers valbers left a comment

Choose a reason for hiding this comment

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

I gave you my two cents with regard to the naming of ObjectRec, but it seems like you don't agree with it. I don't want to die on that hill, so I'm approving this PR.

@xperiandri
Copy link
Collaborator Author

I just want to check again if it still the issue.
And I cannot decide on naming 🙂

@xperiandri xperiandri force-pushed the support-resolver-changing-middlewares branch from e0841dc to eed947a Compare September 10, 2024 13:27
@xperiandri
Copy link
Collaborator Author

@valbers I implemented an alternative solution #492

@xperiandri xperiandri closed this Sep 10, 2024
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