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

In UDF should function arguments with no default be not null e.g. someFunc(arg: UUID!) vs someFunc(arg: UUID) #444

Closed
olirice opened this issue Nov 2, 2023 · 2 comments · Fixed by #446
Assignees
Labels
triage-required Pending triage from maintainers

Comments

@olirice
Copy link
Contributor

olirice commented Nov 2, 2023

Describe the bug
Currently when a function has an argument with no default, it still shows up as nullable in the introspection schema

For example:

begin;

    create function "someFunc" (arg uuid)
        returns int 
        immutable
        language sql
    as $$ select 1; $$;

    select jsonb_pretty(
        graphql.resolve($$
            {
            __type(name: "Query") {
                fields(includeDeprecated: true) {
                    name
                    args {
                      name
                      type {
                        kind
                        name
                        ofType {
                          kind
                          name
                        }
                      }
                    }
                }

            }
            }
        $$)
    );

Returns

                     jsonb_pretty                      
-------------------------------------------------------
 {                                                    +
     "data": {                                        +
         "__type": {                                  +
             "fields": [                              +
                 {                                    +
                     "args": [                        +
                         {                            +
                             "name": "nodeId",        +
                             "type": {                +
                                 "kind": "NON_NULL",  +
                                 "name": null,        +
                                 "ofType": {          +
                                     "kind": "SCALAR",+
                                     "name": "ID"     +
                                 }                    +
                             }                        +
                         }                            +
                     ],                               +
                     "name": "node"                   +
                 },                                   +
                 {                                    +
                     "args": [                        +
                         {                            +
                             "name": "arg",           +
                             "type": {                +
                                 "kind": "SCALAR",    +     -- CAN THIS BE NON-NULL?
                                 "name": "UUID",      +
                                 "ofType": null       +
                             }                        +
                         }                            +
                     ],                               +
                     "name": "someFunc"               +
                 }                                    +
             ]                                        +
         }                                            +
     }                                                +
 }
(1 row)

given that this change would be from nullable to non-null and is only related to inputs, the change would be non-breaking in the API layer

@olirice olirice added the triage-required Pending triage from maintainers label Nov 2, 2023
@olirice olirice assigned olirice and imor and unassigned olirice Nov 2, 2023
@olirice
Copy link
Contributor Author

olirice commented Nov 2, 2023

I'd guess that the reason this doesn't currently happen is because we don't support default arguments #410

but I think it'd still be possible to check if one exists to determine if the function arg is nullable or not

@imor
Copy link
Contributor

imor commented Nov 7, 2023

Yes, non-default args should be non-null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-required Pending triage from maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants