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

New queries not accesible via client #3035

Closed
waltermvp opened this issue Nov 18, 2024 · 16 comments
Closed

New queries not accesible via client #3035

waltermvp opened this issue Nov 18, 2024 · 16 comments
Assignees
Labels
data-schema Gen 2 pending-maintainer-response Issue is pending a response from the Amplify team. question Further information is requested transferred

Comments

@waltermvp
Copy link

Environment information

System:
  OS: macOS 15.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 7.31 GB / 64.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.5.1 - /opt/homebrew/bin/node
  Yarn: 1.22.22 - /opt/homebrew/bin/yarn
  npm: 10.8.2 - /opt/homebrew/bin/npm
  pnpm: 9.12.3 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.5.0
  @aws-amplify/backend: 1.7.0
  @aws-amplify/backend-auth: 1.4.0
  @aws-amplify/backend-cli: 1.4.2
  @aws-amplify/backend-data: 1.2.0
  @aws-amplify/backend-deployer: 1.1.9
  @aws-amplify/backend-function: 1.7.5
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.3
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.2
  @aws-amplify/cli-core: 1.2.0
  @aws-amplify/client-config: 1.5.2
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.2.0
  @aws-amplify/plugin-types: 1.4.0
  @aws-amplify/sandbox: 1.2.5
  @aws-amplify/schema-generator: 1.2.5
  aws-amplify: 6.6.7
  aws-cdk: 2.166.0
  aws-cdk-lib: 2.167.0
  typescript: 5.3.3
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Describe the bug

I am unable to access queries I created on the backend. I am able to see the first query named "purchase", however I have tried adding two more queries "validate" and "sayHello" they do not show up when I log queries and when I try to call the query as a function I get a undefined error. The query does show up in the amlplify playground but not accessible via the client. I presume I am missing a step, but after reviewing the documentation I cannot see where my implementation is wrong.

Reproduction steps

Code is publicly accessible here: public repo.

Observe the console.log (https://github.com/waltermvp/AlfajoresNY/blob/main/src/app/onboarding.tsx#L41)
Screenshot 2024-11-18 at 5 09 13 PM
only contains the purchase function on this deployment https://main.dqfinb0wqqis3.amplifyapp.com/onboarding/. When there should be two more queries available.

@ykethan
Copy link
Member

ykethan commented Nov 19, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Nov 19, 2024
@chrisbonifacio chrisbonifacio self-assigned this Nov 19, 2024
@chrisbonifacio
Copy link
Member

Hi @waltermvp 👋 thanks for raising this issue. Can you confirm that the sandbox redeployed successfully after adding your queries and that they appear in the model introspection schema in the amplify_outputs.json file?

@chrisbonifacio chrisbonifacio added question Further information is requested pending-community-response Issue is pending a response from the author or community. and removed pending-triage labels Nov 19, 2024
@waltermvp
Copy link
Author

@chrisbonifacio thank you for the quick response. Yes they are there:

    "model_introspection": {
      "version": 1,
      "models": {},
      "enums": {},
      "nonModels": {},
      "queries": {
        "sayHello": {
          "name": "sayHello",
          "isArray": false,
          "type": "String",
          "isRequired": false,
          "arguments": {
            "name": {
              "name": "name",
              "isArray": false,
              "type": "String",
              "isRequired": false
            }
          }
        },
        "validate": {
          "name": "validate",
          "isArray": false,
          "type": "String",
          "isRequired": false,
          "arguments": {
            "zipCode": {
              "name": "zipCode",
              "isArray": false,
              "type": "String",
              "isRequired": false
            }
          }
        },
        "purchase": {
          "name": "purchase",
          "isArray": false,
          "type": "String",
          "isRequired": false,
          "arguments": {
            "quantity": {
              "name": "quantity",
              "isArray": false,
              "type": "Int",
              "isRequired": false
            },
            "productId": {
              "name": "productId",
              "isArray": false,
              "type": "String",
              "isRequired": false
            }
          }
        }
      }
    }

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Nov 19, 2024
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Nov 19, 2024

thank you for the response, @waltermvp

i noticed that the screenshot you shared is of the hosted site. for the changes to appear on the hosted site, you need to have pushed any git commits to the deployed branch.

can you confirm that your commits have been merged and deployed?

@waltermvp
Copy link
Author

they are. You can look at the main branch in the repo (it's public). It is what is deployed on the hosted site. I added the console.log for inspection

@chrisbonifacio
Copy link
Member

chrisbonifacio commented Nov 19, 2024

i see this in your main branch: https://github.com/waltermvp/AlfajoresNY/blob/main/src/amplify_outputs.json

this branch name matches the subdomain of the site in your screenshot.

CleanShot 2024-11-19 at 14 24 48@2x

@waltermvp
Copy link
Author

ah your right, I can update the amplify-outputs file in git. I believe it gets overridden by amplify CI during deployment anyways. I can update the amplify outputs file with a npx ampx generate outputs call, or what do you recommend?

@chrisbonifacio
Copy link
Member

npx ampx generate outputs should do the trick!

@waltermvp
Copy link
Author

makes sense, ive made these two commits :

  1. amplify_outputs.json
  2. https://github.com/waltermvp/AlfajoresNY/commit/18bc2da76e70a81e3ef98e419984a1580bf956c1

They should be reflected in the next deployment

@waltermvp
Copy link
Author

@chrisbonifacio
Copy link
Member

chrisbonifacio commented Nov 19, 2024

it doesn't look like the amplify_outputs.json file was updated in the last deployment. this is from the source code loaded by the browser when i visited the site.

CleanShot 2024-11-19 at 15 12 47@2x

@waltermvp
Copy link
Author

@waltermvp
Copy link
Author

waltermvp commented Nov 20, 2024

am I missing something? @chrisbonifacio

@chrisbonifacio
Copy link
Member

chrisbonifacio commented Nov 21, 2024

i think the issue is that you have two amplify_outputs.json files in different places.

  1. https://github.com/waltermvp/AlfajoresNY/blob/main/amplify_outputs.json
  2. https://github.com/waltermvp/AlfajoresNY/blob/main/src/amplify_outputs.json

where you are calling Amplify.configure you are importing the outputs file from the src folder. the one at the root directory of the project is the one that's up to date.

https://github.com/waltermvp/AlfajoresNY/blob/39f49f2f80fe0342b35b70e4accdaedc1f2e75d8/src/app/onboarding.tsx#L22

@chrisbonifacio chrisbonifacio added pending-community-response Issue is pending a response from the author or community. and removed pending-maintainer-response Issue is pending a response from the Amplify team. labels Nov 21, 2024
@waltermvp
Copy link
Author

Oh my you are absolutely right thank you! I will close this issue, thank you for your time

@github-actions github-actions bot removed the pending-community-response Issue is pending a response from the author or community. label Nov 21, 2024
@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 21, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data-schema Gen 2 pending-maintainer-response Issue is pending a response from the Amplify team. question Further information is requested transferred
Projects
None yet
Development

No branches or pull requests

4 participants