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

GraphQL custom scalar types should be type hint mixed in PHP #41

Closed
vuongxuongminh opened this issue Nov 30, 2021 · 2 comments
Closed
Labels
enhancement A feature or improvement

Comments

@vuongxuongminh
Copy link
Contributor

vuongxuongminh commented Nov 30, 2021

Is your feature request related to a problem? Please describe.

My GraphQL server define custom scalar type json's an array like an example at https://graphql.org/learn/schema/#scalar-types but currently generator generate executor method args with PHP type hint's string so I can not pass an array arg to executor.

Example with graphql operation:

query CheckPermissions($userId: Int!, $permissions: json!) {
    permissions_check(permissions: $permissions, user_id: $userId)
}

Will generate an executor method:

    public static function execute(int $userId, string $permissions): CheckPermissions\CheckPermissionsResult
    {
        return self::executeOperation(...func_get_args());
    }

Describe the solution you'd like

In my case above, $permissions should be type hint with mixed type so I can pass an array to it.

For custom scalar types, I think Spawnia\Sailor\Codegen\PhpType::forScalar method should be return mixed type for PHP8 and above and return empty string (mixed too) for lower PHP versions.

@spawnia spawnia added the enhancement A feature or improvement label Dec 8, 2021
@spawnia
Copy link
Owner

spawnia commented Dec 8, 2021

Custom scalars are supported in the latest version, see https://github.com/spawnia/sailor#custom-types

@spawnia spawnia closed this as completed Dec 8, 2021
@vuongxuongminh
Copy link
Contributor Author

Good news! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants