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

Subscriptions via AWS AppSync console gives an error #177

Open
harsh-13799 opened this issue Nov 15, 2024 · 2 comments
Open

Subscriptions via AWS AppSync console gives an error #177

harsh-13799 opened this issue Nov 15, 2024 · 2 comments
Labels
is: bug Something isn't working package: generator Generator package package: server Server package

Comments

@harsh-13799
Copy link

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!

@maoosi
Copy link
Owner

maoosi commented Nov 18, 2024

Hey @harsh-13799 thanks for the detailed report!

You've indeed spotted a bug with the generator, and I was able to reproduce it on my end. You're right that datasource: none should be the default setting for all subscriptions, but it currently isn't. I'll make sure to fix this in the next patch release.

Regarding your "Attempt to Use non Datasource" error, it seems to relate to the amplify-appsync-simulator package, which we use for running AWS AppSync locally. Are you experiencing a similar issue when it's deployed on AWS, or is it only happening locally?

To sum up, I'll look into the issue and aim to release a patch, though I can't provide an exact timeline right now as I’m quite busy with work.

@maoosi maoosi added is: bug Something isn't working package: server Server package package: generator Generator package labels Nov 18, 2024
@harsh-13799
Copy link
Author

harsh-13799 commented Nov 18, 2024

Thanks for your response, @maoosi!

Regarding the "Attempt to Use none Datasource" error, it seems to occur specifically during local testing. Since it’s not functioning correctly locally, I haven't been able to proceed with deploying it on AWS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: bug Something isn't working package: generator Generator package package: server Server package
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants