CanDirective args Argument value is of type 'ArrayValue', expected a scalar
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
I use the GraphQL plugin for intellij suggested by the official docs, but it gives me an error when adding an array to args of @can
The message is:
'createProperty' uses an illegal value for the argument 'args' on directive 'can'. Argument value is of type 'ArrayValue', expected a scalar
Describe the bug
type Mutation {
createProperty(input: PropertyCreationInput @spread): Property @can(ability: "wp:role", args: [1,2], model: "App\\Models\\User")
}
So the args with [1,2] is the problem.
This is the defined type at schema-directives.graphql which comes from /vendor/nuwave/lighthouse/src/Auth/CanDirective.php
"""
Any constant literal value: https://graphql.github.io/graphql-spec/draft/#sec-Input-Values
"""
scalar CanArgs
Shouldn't that be something like instead?
scalar CanArgs @scalar(class: "a class here")
Expected behavior/Solution
Steps to reproduce
- You can just use the example from the docs and add the args to it:
type Mutation {
createBlogPost(input: PostInput!): BlogPost
@can(ability: "create", model: "App\\Post", args: [1,2])
}
- You can now see
createBlogPostis underlined and red in intellij with this error:'createBlogPost' uses an illegal value for the argument 'args' on directive 'can'. Argument value is of type 'ArrayValue', expected a scalar
Output/Logs
Click to expand
# Add in log output/error messages here
Lighthouse Version : v5.67.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CanArgs definition in schema-directives.graphql and the corresponding /vendor/nuwave/lighthouse/src/Auth/CanDirective.php entry point. Reproduce the reported args: [1,2] example in the IntelliJ GraphQL plugin, then verify that the schema definition and editor validation agree on the accepted argument value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100