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

unable to specify default value for query, mutation arguments #2802

Open
josefaidt opened this issue Aug 22, 2024 · 2 comments
Open

unable to specify default value for query, mutation arguments #2802

josefaidt opened this issue Aug 22, 2024 · 2 comments
Labels
bug Something isn't working Gen 2 transferred

Comments

@josefaidt
Copy link
Contributor

Environment information

System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 90.34 MB / 32.00 GB
  Shell: /opt/homebrew/bin/fish
Binaries:
  Node: 20.16.0 - ~/.local/state/fnm_multishells/24303_1724345506467/bin/node
  Yarn: undefined - undefined
  npm: 10.8.1 - ~/.local/state/fnm_multishells/24303_1724345506467/bin/npm
  pnpm: 9.7.0 - ~/.local/state/fnm_multishells/24303_1724345506467/bin/pnpm
NPM Packages:
  @aws-amplify/auth-construct: Not Found
  @aws-amplify/backend: 1.1.1
  @aws-amplify/backend-auth: Not Found
  @aws-amplify/backend-cli: 1.2.4
  @aws-amplify/backend-data: Not Found
  @aws-amplify/backend-deployer: Not Found
  @aws-amplify/backend-function: Not Found
  @aws-amplify/backend-output-schemas: Not Found
  @aws-amplify/backend-output-storage: Not Found
  @aws-amplify/backend-secret: Not Found
  @aws-amplify/backend-storage: Not Found
  @aws-amplify/cli-core: Not Found
  @aws-amplify/client-config: Not Found
  @aws-amplify/deployed-backend-client: Not Found
  @aws-amplify/form-generator: Not Found
  @aws-amplify/model-generator: Not Found
  @aws-amplify/platform-core: Not Found
  @aws-amplify/plugin-types: Not Found
  @aws-amplify/sandbox: Not Found
  @aws-amplify/schema-generator: Not Found
  aws-amplify: 6.5.2
  aws-cdk: 2.154.0
  aws-cdk-lib: 2.154.0
  typescript: 5.5.4
AWS environment variables:
  AWS_PROFILE = josef
  AWS_REGION = us-east-1
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

I am building a query that has an optional argument

const schema = a.schema({
  sayHello: a
    .query()
    .arguments({
      name: a.string().default("World"),
    })
    .returns(a.string()),
})

However I am encountering this error when attempting to deploy

Failed to instantiate data construct
Caused By: Schema validation failed.\n\nDirective "@default" may not be used on ARGUMENT_DEFINITION.\n\nGraphQL request:7:25\n6 | type Query {\n7 |   sayHello(name: String @default(value: "World")): String \n  |                         ^\n8 | } 

Resolution: See the underlying error message for more details.

with --debug

Directive "@default" may not be used on ARGUMENT_DEFINITION.
  
  GraphQL request:7:25
  6 | type Query {
  7 |   sayHello(name: String @default(value: "World")): String 
    |                         ^
  8 | } 

Instead I would expect

type Query {
  sayHello(name: String = "World"): String
}
@ykethan
Copy link
Member

ykethan commented Aug 23, 2024

Transferring this over to API repository.

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Aug 23, 2024
@AnilMaktala
Copy link
Member

Hey Josef, We were able to reproduce the issue, so we're marking it as a bug for the team to evaluate further.

image

@AnilMaktala AnilMaktala added bug Something isn't working and removed pending-triage labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Gen 2 transferred
Projects
None yet
Development

No branches or pull requests

3 participants