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.

"Validation error of type SubSelectionRequired" during sync

See original GitHub issue

I am having trouble syncing with Datastore.

Here is a snippet of our schema:

interface IEntity {
  id: ID!
  insightsId: Int
}

interface ITask {
  insightsId: Int
  type: TaskType!
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
  comment: String
  dueDate: AWSDateTime
  isAnytime: Boolean
  customerId: ID
  assigneeName: String!
  editedBy: String!
  reminder: Reminder
}

type Task implements ITask & IEntity {
  id: ID!
  insightsId: Int
  type: TaskType!
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
  comment: String
  dueDate: AWSDateTime
  isAnytime: Boolean
  customerId: ID
  assigneeName: String!
  editedBy: String!
  reminder: Reminder
  visitId: Int
  endTime: String
  _version: Int!
  _deleted: Boolean
  _lastChangedAt: AWSTimestamp!
}

type Reminder {
  offSet: String
  date: AWSDateTime
}

enum TaskType {
  TASK
  SCHEDULED
}

When the app starts up with a valid signed-in user, the app shows the following log output:

W/amplify:aws-datastore: Failed to sync down cloud state for model type = Task
AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='Validation error of type SubSelectionRequired: Sub selection required for type Reminder of field reminder @ 'syncTasks/items/reminder'', locations='[GraphQLLocation{line='14', column='7'}]', path='null', extensions='null'}], cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0$AppSyncClient(AppSyncClient.java:107)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$DAlM2A4r8A_52MV-BaSjc1SYWao.accept(lambda)
        at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse(AppSyncGraphQLOperation.java:140)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

It looks a lot like https://github.com/aws-amplify/amplify-ios/issues/529, marked as closed in the iOS library.

When I run a Task query on the AppSync query page, it seems to respond with the correct data (though it looks like the editor specifies the leaf fields for you).

More log context:

2020-08-06 08:45:38.032 8214-8947/com.skynamo.appid W/amplify:aws-datastore: Failed to sync down cloud state for model type = Task
    AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='Validation error of type SubSelectionRequired: Sub selection required for type Reminder of field reminder @ 'syncTasks/items/reminder'', locations='[GraphQLLocation{line='14', column='7'}]', path='null', extensions='null'}], cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0$AppSyncClient(AppSyncClient.java:107)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$DAlM2A4r8A_52MV-BaSjc1SYWao.accept(lambda)
        at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse(AppSyncGraphQLOperation.java:140)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
2020-08-06 08:45:38.032 8214-8947/com.skynamo.appid W/amplify:aws-datastore: Initial cloud sync failed.
    AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='Validation error of type SubSelectionRequired: Sub selection required for type Reminder of field reminder @ 'syncTasks/items/reminder'', locations='[GraphQLLocation{line='14', column='7'}]', path='null', extensions='null'}], cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0$AppSyncClient(AppSyncClient.java:107)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$DAlM2A4r8A_52MV-BaSjc1SYWao.accept(lambda)
        at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse(AppSyncGraphQLOperation.java:140)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
2020-08-06 08:45:38.032 8214-8947/com.skynamo.appid E/amplify:aws-datastore: Error encountered in the DataStore.
    AmplifyException {message=Initial cloud sync failed., cause=AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='Validation error of type SubSelectionRequired: Sub selection required for type Reminder of field reminder @ 'syncTasks/items/reminder'', locations='[GraphQLLocation{line='14', column='7'}]', path='null', extensions='null'}], cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Check your internet connection.}
        at com.amplifyframework.datastore.syncengine.SyncProcessor.lambda$null$2$SyncProcessor(SyncProcessor.java:122)
        at com.amplifyframework.datastore.syncengine.-$$Lambda$SyncProcessor$3L2KTfMEy6_59oCr_DedPu68KAo.accept(lambda)
        at io.reactivex.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:88)
        at io.reactivex.internal.operators.completable.CompletableAndThenCompletable$SourceObserver.onError(CompletableAndThenCompletable.java:62)
        at io.reactivex.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onError(SingleFlatMapCompletable.java:97)
        at io.reactivex.internal.operators.observable.ObservableFlatMapCompletableCompletable$FlatMapCompletableMainObserver.onError(ObservableFlatMapCompletableCompletable.java:126)
        at io.reactivex.internal.operators.observable.ObservableFlattenIterable$FlattenIterableObserver.onError(ObservableFlattenIterable.java:125)
        at io.reactivex.internal.observers.BasicFuseableObserver.onError(BasicFuseableObserver.java:100)
        at io.reactivex.internal.operators.observable.ObservableToList$ToListObserver.onError(ObservableToList.java:92)
        at io.reactivex.internal.operators.mixed.SingleFlatMapObservable$FlatMapObserver.onError(SingleFlatMapObservable.java:74)
        at io.reactivex.internal.operators.single.SingleDoOnError$DoOnError.onError(SingleDoOnError.java:63)
        at io.reactivex.internal.operators.single.SingleDoOnSuccess$DoOnSuccess.onError(SingleDoOnSuccess.java:65)
        at io.reactivex.internal.operators.single.SingleCreate$Emitter.tryOnError(SingleCreate.java:94)
        at io.reactivex.internal.operators.single.SingleCreate$Emitter.onError(SingleCreate.java:80)
        at com.amplifyframework.datastore.syncengine.-$$Lambda$3TQsNIUgAvjdYqsJiM71fw48re0.accept(lambda)
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0$AppSyncClient(AppSyncClient.java:106)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$DAlM2A4r8A_52MV-BaSjc1SYWao.accept(lambda)
        at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse(AppSyncGraphQLOperation.java:140)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='Validation error of type SubSelectionRequired: Sub selection required for type Reminder of field reminder @ 'syncTasks/items/reminder'', locations='[GraphQLLocation{line='14', column='7'}]', path='null', extensions='null'}], cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0$AppSyncClient(AppSyncClient.java:107)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$DAlM2A4r8A_52MV-BaSjc1SYWao.accept(lambda) 
        at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse(AppSyncGraphQLOperation.java:140) 
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 
2020-08-06 08:45:38.034 8214-8679/com.skynamo.appid I/amplify:aws-datastore: Starting processing subscription data buffer.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
endigocommented, Sep 5, 2020

@jpignata Hey is it included in 1.3.1? I think it’s not included in this version.

0reactions
jamesonwilliamscommented, Sep 15, 2020

#801 went out in 1.3.2. Please give this latest version a try, and let us know if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sub selection required for type null of field - Stack Overflow
When I query for customer without 'carsInterested', it works properly. Any idea why I am getting this error? Thanks. graphql · graphql-java.
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 >
validation error of type fieldundefined graphql
validation error of type subselectionrequired. When requesting a field that resolves to an object type (or a list of an object type), you...
Read more >
Sub selection required for type Timestamp of field-Springboot
Coding example for the question Validation error of type SubSelectionRequired: Sub selection required for type Timestamp of field-Springboot.
Read more >
Query record data using the GraphQL API framework
Sync the current file between a Visual Studio Code workspace and ... Write a script for an automation message variable in Automation Center....
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