Is it possible for Amplify DataStore to skip a table on client, but to create a DynamoDB table for a scheme type


Hi, In our amplify app we have a table that can contain huge text fields, so we would prefer to work with this data on AppSync/QraphQL level without DataStore. Is it possible to declare the scheme in such a way so the DataStore doesn't even try to sync that model? If I get it right from the docs [1] @model directive is required for Amplify to generate DynamoDB table (and for the @searchable to work). So we currently added an DataStore config on syncExpressions to prevent the sync, but that approach seems odd, so I hope it's possible to exclude the table from DataStore altogether?

for the example:

type Document @model(subscriptions: { level: off }) @auth(rules: [{ allow: owner}]) @searchable {
    id: ID! @primaryKey
    content: AWSJSON!
    DataStore: {
        syncExpressions: [
            syncExpression(Document, doc => doc?.id('eq', '0'))

We still receive warnings with this approach, I guess they are caused by the subscription off param in @model derective

recoverable error {error: {…}}error: cause: {provider: AWSAppSyncRealTimeProvider, error: {…}}errorType: "Unknown"localModel: nullmessage: "Connection failed: {\"errors\":[{\"message\":\"Validation error of type FieldUndefined: Field 'onUpdateDocument' in type 'Subscription' is undefined @ 'onUpdateDocument'\"}]}"model: "Document"operation: "Update"process: "subscribe"recoverySuggestion: "Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue:"remoteModel: null[[Prototype]]: Object[[Prototype]]: Object
overrideMethod @ react_devtools_backend_compact.js:2367
errorHandler @ index.tsx:39
(anonymous) @ subscription.ts:450
step @ mutation.ts:574

there are similar errors for onCreateDocument and onDeleteDocument

[1] -

feita há um ano727 visualizações
2 Respostas
Resposta aceita


From your query, I understand that you would like to use the Document table directly without configuring the DataStore for it. You have tried to configure the DataStore configuration for syncExpression on the table to prevent the syncing of the data. However, you are observing the error on subscription for the generated schema.

Please note that, unfortunately, at the moment, the disabling of DataStore for a specific model is not supported in Amplify applications. DataStore can be enabled or disabled for the entire Amplify project at once using the amplify update api command. There is an active feature request with Amplify service team on this issue. You can track this FR on the same GitHub issue. It also mentions the workaround of disabling the sync as you mentioned. We can leverage the same workaround to prevent the DataStore sync of the table.

Having said that, for the error you are observing, this is being returned as the subscriptions are not being generated for the Document model. I tried replicating this warning in my sample application however, I did not received this error. To further investigate on this, we would need to check if there is no subscription connection being established for the Document model. For more information, please refer subscribing to data.

I hope you find above information helpful. In case you require further assistance specific to the above error being observed, please share if the subscription connection is being established from the application. You may also reach out to us via a Support case.

Have a nice day ahead!

respondido há um ano

Hi @Shadab_A, I was thinking today, that what if I don't even need the GraphQL API for that model. All work with it is done through custom backend code on Node.js. I save the data through AWS SDK DynamoDB API, and query it on client only through my custom NodeJS endpoints and the OpenSearch AppSync API generated from the @searchable. Can I than skip the table on front-end by the workaround I mentioned at the github issue[1]? (in short, simply by removing the model from the scheme before running amplify codegen models)

Or will it have some other impact that I don't see at the moment?

[1] -

respondido há um ano
  • Hello,

    Thank you for writing back.

    In case you generate the models using the method defined in the GitHub issue, it may work until the changes are not being make to the GraphQL API or the command amplify codegen model. These would generate the models again and might cause issues in future. This has been addressed by Amplify service team on the GitHub comment:

    Let me know in case you have any follow up questions!

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas