Skip to content

Error while executing GraphQL statement Error: Must provide Source. Received: undefined #147

@pkubat

Description

@pkubat

Describe the bug
This is a direct lambda query/datasource. It works fine deployed to AWS but dies not to work locally. Not sure how to debug/trace as SLS_DEBUG does not generate traces or output from the queries.

To Reproduce
npx sls offline start and query the service

sample query

curl -X "POST" "http://localhost:20002/graphql" \
     -H 'x-api-key: 0123456789' \
     -H 'Content-Type: application/graphql' \
     -d $'{
	"query": "query MyQuery{listBooks{title}}",
	"variables": {}
}'

Expected behavior

Screenshots

Additional context

  plugins: [
    'serverless-appsync-plugin',
    'serverless-appsync-simulator',
    'serverless-offline',
    'serverless-esbuild',
  ],
    appSync: {
      name: 'service-members-ledgers',
      authenticationType: 'API_KEY',
      apiKeys: [ {
        name: 'key 1',
        description: 'asdasd',
        expiresAfter: '30d',
      }],
      mappingTemplates: [{
        type: 'Query',
        request: false,
        response: false,
        dataSource: '_ds_appSyncTest',
        field: 'listBooks',
      }],
      dataSources: [{
        type: 'AWS_LAMBDA',
        name: '_ds_appSyncTest',
        config: {
          functionName: 'appSyncTest'
        }
      }],
    },

SLS+DEBUG=*

AppSync Simulator: AppSync Config service-members-ledgers
AppSync Simulator: {
  appSync: {
    name: 'service-members-ledgers',
    apiKey: '0123456789',
    defaultAuthenticationType: { authenticationType: 'API_KEY' },
    additionalAuthenticationProviders: []
  },
  schema: {
    path: 'schema.graphql',
    content: 'schema {\n' +
      '  query: Query\n' +
      '}\n' +
      '\n' +
      'type Book {\n' +
      '  title: String\n' +
      '}\n' +
      '\n' +
      'type Query {\n' +
      '  listBooks: [Book]\n' +
      '}'
  },
  resolvers: [
    {
      kind: 'UNIT',
      fieldName: 'listBooks',
      typeName: 'Query',
      dataSourceName: '_ds_appSyncTest',
      functions: undefined,
      requestMappingTemplate: '## Direct lambda request\n' +
        '{\n' +
        '    "version": "2018-05-29",\n' +
        '    "operation": "Invoke",\n' +
        '    "payload": $utils.toJson($context)\n' +
        '}\n',
      responseMappingTemplate: '## Direct lambda response\n' +
        '#if($ctx.error)\n' +
        '    $util.error($ctx.error.message, $ctx.error.type, $ctx.result)\n' +
        '#end\n' +
        '$util.toJson($ctx.result)\n'
    }
  ],
  dataSources: [
    {
      name: '_ds_appSyncTest',
      type: 'AWS_LAMBDA',
      invoke: [AsyncFunction: invoke]
    }
  ],
  functions: []
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions