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

DataStore sync failing for connected Model without auth directive #622

Closed
lawmicha opened this issue Jul 7, 2020 · 6 comments
Closed

DataStore sync failing for connected Model without auth directive #622

lawmicha opened this issue Jul 7, 2020 · 6 comments
Assignees
Labels
api Issues related to the API category bug Something isn't working closing soon This issue will be closed in 7 days unless further comments are made. datastore Issues related to the DataStore category pending-community-response Issue is pending response from the issue requestor

Comments

@lawmicha
Copy link
Contributor

lawmicha commented Jul 7, 2020

Hi, I am also facing same issue while using graphql api with amazon cognito as default authentication. It continuously tries to connect to the api but always failing. I have taken care of everything as mentioned by @lawmicha for @auth directive. My ios App is unable to sync the data with the cloud. I have checked the recieptmodel app by @lawmicha and has done everything same like it but still I'm not able fulfill my purpose. I am attaching my schema with it and even though I have signed in still the app is unable to connect with the api.
Screenshot 2020-07-05 at 3 27 13 AM
Screenshot 2020-07-05 at 3 27 27 AM

Screenshot 2020-07-05 at 3 25 39 AM

Originally posted by @aken27 in #561 (comment)

@lawmicha lawmicha changed the title Hi, I am also facing same issue while using graphql api with amazon cognito as default authentication. It continuously tries to connect to the api but always failing. I have taken care of everything as mentioned by @lawmicha for @auth directive. My ios App is unable to sync the data with the cloud. I have checked the recieptmodel app by @lawmicha and has done everything same like it but still I'm not able fulfill my purpose. I am attaching my schema with it and even though I have signed in still the app is unable to connect with the api. DataStore sync failing for connected Model without auth directive Jul 7, 2020
@lawmicha
Copy link
Contributor Author

lawmicha commented Jul 7, 2020

hi @aken27, It appears the provisioned backend requires owner authorization on Items when there is a connection from Categories when Categories require owner auth. The library is not aware of this requirement since it is not explicitly added on the Items type. We can take this as a bug and make sure the library can account for this case.

A workaround here is to specify allow: owner on the Items

type Category @model @auth(rules: [ {allow: owner}]) {
    id: ID!
    name: String!
    color: String!
    items: [Item] @connection
}

type Item @model @auth(rules: [ {allow: owner}]){
    id: ID!
    title: String!
    done: Boolean!
    categoryID: ID!
}

@lawmicha lawmicha added api Issues related to the API category datastore Issues related to the DataStore category bug Something isn't working labels Jul 7, 2020
@github-actions
Copy link
Contributor

This issue is stale because it has been open 14 days with no activity. Please, provide an update or this will be automatically closed in 7 days.

@github-actions github-actions bot added the closing soon This issue will be closed in 7 days unless further comments are made. label Oct 13, 2020
@drochetti
Copy link
Contributor

@wooj2 and @diegocstn this seems related to the work you have been doing. Can you double check if this issue is still relevant?

@drochetti drochetti added follow up Requires follow up from maintainers and removed closing soon This issue will be closed in 7 days unless further comments are made. labels Oct 13, 2020
@diegocstn diegocstn self-assigned this Oct 14, 2020
@diegocstn
Copy link
Contributor

Hi @aken27,
with #815 a failing model subscription shouldn't halt the DataStore sync engine anymore.

There's also a separate issue with the usage of @connection without arguments in a has-many relationship that will cause the subscription to fail with an error similar to what as been reported in #828.

I'd suggest as a workaround to update the schema


type Category @model @auth(rules: [ {allow: owner} ]) {
    id: ID!
    name: String!
    color: String!
    items: [Item] @connection(keyName: "byCategory", fields: ["id"])
}

type Item @model @auth(rules: [ {allow: owner} ]) @key(name: "byCategory", fields: ["categoryID"]) {
    id: ID!
    title: String!
    done: Boolean!
    categoryID: ID!
}

@diegocstn diegocstn removed the follow up Requires follow up from maintainers label Oct 16, 2020
@drochetti drochetti added the pending-community-response Issue is pending response from the issue requestor label Oct 26, 2020
@github-actions
Copy link
Contributor

This issue is stale because it has been open for 14 days with no activity. Please, provide an update or it will be automatically closed in 7 days.

@github-actions github-actions bot added the closing soon This issue will be closed in 7 days unless further comments are made. label Nov 10, 2020
@github-actions
Copy link
Contributor

This issue is being automatically closed due to inactivity. If you believe it was closed by mistake, provide an update and re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category bug Something isn't working closing soon This issue will be closed in 7 days unless further comments are made. datastore Issues related to the DataStore category pending-community-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

3 participants