question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding lambda resolver results in "TypeError: Must Provide Source" when running query

See original GitHub issue

Describe the bug Having worked on a project for a while, the ability to add new lambda resolvers is suddenly broken.

I add the lambda as follows:

amplify add function                                                                         
? Select which capability you want to add: Lambda function (serverless function)
? Provide a friendly name for your resource to be used as a label for this category in the project: moo
? Provide the AWS Lambda function name: moo
? Choose the runtime that you want to use: Python
Only one template found - using Hello World by default.
? Do you want to access other resources in this project from your Lambda function? No
? Do you want to invoke this function on a recurring schedule? No
? Do you want to configure Lambda layers for this function? No
? Do you want to edit the local lambda function now? Yes
Please edit the file in your editor: /Users/halfdan/vuzz/repos/yoor/app/amplify/backend/function/moo/src/index.py
? Press enter to continue
Successfully added resource moo locally.

Next steps:
Check out sample function code generated in <project-dir>/amplify/backend/function/moo/src
"amplify function build" builds all of your functions currently in the project
"amplify mock function <functionName>" runs your function locally
"amplify push" builds all of your local backend resources and provisions them in the cloud
"amplify publish" builds all of your local backend and front-end resources (if you added hosting category) and provisions them in the cloud

and adds the query to the gql schema:

type Query {
  echo(msg: String): String @function(name: "yoorecho-${env}")
  foo(msg: String): String @function(name: "yoorecho-${env}")
  bar(msg: String): String @function(name: "yoorbar-${env}")
  moo(msg: String): String @function(name: "yoormoo-${env}")
}

then run amplify push

When I then run the query moo in my app, the following error happens:

ERROR TypeError: Must provide Source. Received: undefined
    at parse (parser.mjs:27)
    at GraphQLAPIClass.graphql (GraphQLAPI.ts:191)
    at APIClass.graphql (API.ts:194)
    at fetchUser (index.tsx:56)
    at index.tsx:73
    at commitHookEffectListMount (react-dom.development.js:19731)
    at commitPassiveHookEffects (react-dom.development.js:19769)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at flushPassiveEffectsImpl (react-dom.development.js:22853)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at performSyncWorkOnRoot (react-dom.development.js:21737)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at scheduleUpdateOnFiber (react-dom.development.js:21199)
    at dispatchAction (react-dom.development.js:15660)
    at withAuthenticator.tsx:42
    at step (index.tsx:29)
    at Object.next (index.tsx:29)
    at fulfilled (index.tsx:29)

Note that echo, foo and bar queries, backed by lambda resolvers added earlier, all work fine!

amplify mock function moo works fine.

The only big change I did recently was to add a new env. I can’t say if that’s what messed things up though.

To Reproduce Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Expected behavior The query to execute

Code Snippet Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)

Screenshots If applicable, add screenshots to help explain your problem.

What is Configured? If applicable, please provide what is configured for Amplify CLI:

  • Which steps did you follow via Amplify CLI when configuring your resources.
  • Which resources do you have configured?
    • If applicable, please provide your aws-exports file:

aws-exports:

const awsmobile = {
    "aws_project_region": "ap-northeast-1",
    "aws_cognito_identity_pool_id": "ap-northeast-1:69ff8753-e532-4601-826f-948369fca16b",
    "aws_cognito_region": "ap-northeast-1",
    "aws_user_pools_id": "ap-northeast-1_TUy2VI5Jl",
    "aws_user_pools_web_client_id": "2rkdeu4l58djdf7echpp1a5t0e",
    "oauth": {
        "domain": "seesaayoorapp78701dff-78701dff-hdev.auth.ap-northeast-1.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "http://localhost:3000/",
        "redirectSignOut": "http://localhost:3000/",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_POOLS",
    "aws_appsync_graphqlEndpoint": "https://pfehe4a4rvbhlpqynk4476heam.appsync-api.ap-northeast-1.amazonaws.com/graphql",
    "aws_appsync_region": "ap-northeast-1",
    "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS"
};
  • If applicable, provide more configuration data, for example for Amazon Cognito, run aws cognito-idp describe-user-pool --user-pool-id us-west-2_xxxxxx (Be sure to remove any sensitive data)
Environment
npx: installed 1 in 1.314s

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Memory: 349.95 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.16.0 - /usr/local/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 86.0.4240.75
    Firefox: 81.0
    Safari: 13.1.2
  npmPackages:
    @aws-amplify/ui-react: ^0.2.18 => 0.2.18
    @material-ui/core: ^4.11.0 => 4.11.0
    @material-ui/icons: ^4.9.1 => 4.9.1
    @testing-library/jest-dom: ^4.2.4 => 4.2.4
    @testing-library/react: ^9.5.0 => 9.5.0
    @testing-library/user-event: ^7.2.1 => 7.2.1
    @types/jest: ^24.9.1 => 24.9.1
    @types/node: ^12.12.55 => 12.12.55
    @types/react: ^16.9.49 => 16.9.49
    @types/react-dom: ^16.9.8 => 16.9.8
    @types/react-router-dom: ^5.1.5 => 5.1.5
    @types/react-router-hash-link: ^1.2.1 => 1.2.1
    aws-amplify: ^3.1.1 => 3.1.1
    faker: ^5.1.0 => 5.1.0
    md5: ^2.3.0 => 2.3.0
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-router-dom: ^5.2.0 => 5.2.0
    react-router-hash-link: ^2.1.0 => 2.1.0
    react-scripts: 3.4.3 => 3.4.3
    typescript: ^3.9.7 => 3.9.7
  npmGlobalPackages:
    @aws-amplify/cli: 4.27.3
    md5: 2.2.1
    n: 6.7.0
    npm-upgrade: 2.0.4
    npm: 6.13.4
    ts-node: 8.10.2
    typescript: 3.8.2

Additional context Add any other context about the problem here.

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
yuthcommented, Oct 13, 2020

This looks like an issue with the library. @ashika01 could you investigate further why this error gets thrown

1reaction
ashika01commented, Oct 16, 2020

@halfdanrump Someone from the team would look into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding lambda resolver results in "TypeError: Must Provide ...
Adding lambda resolver results in "TypeError: Must Provide Source" ... When I then run the query moo in my app, the following error...
Read more >
AWS Amplify Graphql - TypeError: Must provide Source. ...
I am new to aws amplify so still learning! I have used amplify add api and then amplify push to push my schema...
Read more >
Troubleshooting and Common Mistakes - AWS AppSync
This section discusses some common errors and how to troubleshoot them. Incorrect DynamoDB Key Mapping. If your GraphQL operation returns the following ...
Read more >
Full Stack Error Handling with GraphQL and Apollo
If networkError is present in your response, it means your entire query was rejected, and therefore no data was returned. For example, the ......
Read more >
API (GraphQL) - Configure Lambda resolvers - Amplify Docs
If you deployed your API without amplify then you must provide the full Lambda function name. If you deployed the same function with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found