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

Rules don't work an array of a custom type input #930

Open
leonardocustodio opened this issue Jul 14, 2022 · 7 comments
Open

Rules don't work an array of a custom type input #930

leonardocustodio opened this issue Jul 14, 2022 · 7 comments
Labels

Comments

@leonardocustodio
Copy link
Contributor

Versions:

  • graphql-laravel Version: 8.3.0
  • Laravel Version: 9.10
  • PHP Version: 8.1.8

Description:

Rules don't work properly when they are in a type inside of a list.

I have a mutation called BatchMint with the following args:

    public function args(): array
    {
        return [
            'collectionId' => [
                'type' => GraphQL::type('BigInt!'),
                'description' => 'The Collection ID to mint from.',
            ],
            'recipients' => [
                'type' => GraphQL::type('[MintRecipient!]!'),
            ],
        ];
    }

MintRecipient has the following fields:

    public function fields(): array
    {
        return [
            'address' => [
                'type' => GraphQL::type('String!'),
                'description' => 'The recipient of the token.',
                'rules' => ['filled', new ValidSubstrateAddress],
            ],
            'createParams' => [
                'type' => GraphQL::type('CreateTokenParams'),
                'rules' => ['prohibits:mintParams'],
            ],
            'mintParams' => [
                'type' => GraphQL::type('MintTokenParams'),
                'rules' => ['prohibits:createParams'],
            ],
        ];
    }

The rules on the address field work fine. But the prohibits, required_unless, required_without, or any rule that makes a reference to another field don't work. I know those rules work fine when they are in the arguments but they don't work when they are in the array of types.

@mfn
Copy link
Collaborator

mfn commented Jul 14, 2022

Can you create a PR with a test showing the (unexpected) behavior? The idea being that the test is green but based on the current behavior to have a point of reference.

@leonardocustodio
Copy link
Contributor Author

Sure, I can do it in a few hours 😄

@leonardocustodio leonardocustodio mentioned this issue Jul 14, 2022
9 tasks
@leonardocustodio
Copy link
Contributor Author

@mfn here it is probably not the best names but enough to understand what is happening #931

@mfn
Copy link
Collaborator

mfn commented Jul 15, 2022

Appreciated, will take a look after I'm back from vacation

@leonardocustodio
Copy link
Contributor Author

Thank you, hope you enjoy your vacation. I've just left to mine, otherwise I could take a better look at this 😅

@crissi
Copy link
Contributor

crissi commented Sep 26, 2022

yeah, right now this only works if you do: prohibits:recipients.mintParams so it is dependent on the whole path which is not ideal

@mfn
Copy link
Collaborator

mfn commented Jun 26, 2023

Maybe this is something for a known limitation section, with an example how to work with this?

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

No branches or pull requests

3 participants