Skip to content

Subscriptions via AWS AppSync console gives an error  #177

@harsh-13799

Description

@harsh-13799

I am encountering errors when using the default subscription generated by the prisma-appsync package in the AWS AppSync console.

Error with Default Subscription

When trying to use a subscription, I receive the following error:

{
    "errors": [
        {
            "message": "Connection failed: {\"errors\":[{\"errorType\":\"Error\",\"message\":\"{\\\"error\\\":\\\"sa[s.context.action] is not a function\\\",\\\"type\\\":\\\"INTERNAL_SERVER_ERROR\\\",\\\"code\\\":500}\"}]}"
        }
    ]
}

I found that if I manually update the subscription resolver to use <resourceName>NoneDataSource, the subscription works without errors. However, this manual change is reset after each deployment, which is not ideal.

Attempt to Use none DataSource

To avoid manual updates, I tried modifying(by extending and tweaking schema.prisma) the resolvers.yaml file to use datasource: none instead of datasource: prisma-appsync for subscriptions. However, running yarn dev results in the following error:

\node_modules\amplify-appsync-simulator\lib\resolvers\unit-resolver.js:12
            throw new Error(`Invalid config for UNIT_RESOLVER ${JSON.stringify(config)} \n ${e.message}`);
                  ^

Error: Invalid config for UNIT_RESOLVER {"typeName":"Subscription","fieldName":"onCreatedFile","dataSource":"none","dataSourceName":"none","kind":"UNIT","requestMappingTemplateLocation":"lambdaRequest.vtl","responseMappingTemplateLocation":"lambdaResponse.vtl"}
 Missing data source none
    at new AppSyncUnitResolver (\node_modules\amplify-appsync-simulator\src\resolvers\unit-resolver.ts:12:13)
    at \node_modules\amplify-appsync-simulator\src\index.ts:106:15
    at Array.reduce (<anonymous>)
    at AmplifyAppSyncSimulator.init (\node_modules\amplify-appsync-simulator\src\index.ts:98:49)
    at Object.start (\node_modules\prisma-appsync\dist\server\index.js:22:3466)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Proxy.createServer (\node_modules\prisma-appsync\dist\server\index.js:22:4301)

Questions

  1. If I decide to use datasource: prisma-appsync for subscriptions to avoid manual updates, what changes are required to fix the first error ("sa[s.context.action] is not a function")?
  2. Is it valid to use datasource: none for subscriptions by extending the schema? If so, how can I resolve the Invalid config for UNIT_RESOLVER error?

If further details are needed, I’m happy to provide them. Thank you in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions