aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Error when changing to another appId #11580

Closed ErhardScampi closed 1 year ago

ErhardScampi commented 1 year ago

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

GraphQL API

Amplify Categories

auth, storage, function, api

Environment information

``` # Put output below this line daphne code$ npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages undefined:5 <% if (pkg.author) { %> "author": <%= JSON.stringify(pkg.author) %>,<% } %> ^ SyntaxError: Unexpected token < in JSON at position 109 at JSON.parse () at /Users/sc/.npm/_npx/e8a92db577883955/node_modules/envinfo/dist/envinfo.js:1:1715 at async Promise.all (index 1) at async Promise.all (index 1) at async Promise.all (index 1) at async Promise.all (index 21) ```

Describe the bug

I develop und a certain appID. I push to a feature/branch and a build is started. Everything works fine.

When the app is hopefully ready I push to master a build runs there(other appId) Then I start the the remote hosted app and I get the following error :

errors : Array(68) 0 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'ID' wit…llTag' (/userByCognitoId/items[0]/FullTags[0]/id)"} 1 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'String'…' (/userByCognitoId/items[0]/FullTags[0]/tagName)"} 2 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'AWSDate…(/userByCognitoId/items[0]/FullTags[0]/createdAt)"} 3 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'AWSDate…(/userByCognitoId/items[0]/FullTags[0]/updatedAt)"} 4 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'ID' wit…llTag' (/userByCognitoId/items[0]/FullTags[1]/id)"} 5 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'String'…' (/userByCognitoId/items[0]/FullTags[1]/tagName)"} 6 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'AWSDate…(/userByCognitoId/items[0]/FullTags[1]/createdAt)"} 7 : {path: Array(6), locations: null, message: "Cannot return null for non-nullable type: 'AWSDate…(/userByCognitoId/items[0]/FullTags[1]/updatedAt)"} 8 : .........

68 in sum

Then I pulled local (deleting the amplify folder first) I get the same 68 errors.

remote and local build env are the same 12.1.1. and node 16.8.0

Do I have to migrate the cognitoUsers somehow ?

Expected behavior

Applikation should run as the same like in dev environment

Reproduction steps

I think You need 2 environments with different appId.

build one env with an older version of amplify (7) But some user and data in.

Mak a new env with 12.1.1 and deploy the app to the first one.

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

const awsmobile = { "aws_project_region": "eu-central-1", "aws_appsync_graphqlEndpoint": "https://xhidden.appsync-api.eu-central-1.amazonaws.com/graphql", "aws_appsync_region": "eu-central-1", "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS", "aws_appsync_apiKey": "hidden", "aws_cognito_identity_pool_id": "eu-central-1:1hidden9-4b89-93cf-66236f9c176c", "aws_cognito_region": "eu-central-1", "aws_user_pools_id": "eu-central-1hiddena", "aws_user_pools_web_client_id": "2enhiddenu9i23fa", "oauth": {}, "aws_cognito_username_attributes": [], "aws_cognito_social_providers": [], "aws_cognito_signup_attributes": [ "EMAIL" ], "aws_cognito_mfa_configuration": "OFF",

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

ErhardScampi commented 1 year ago

As attachment my graphql. ID is alway mandatory. I did not change for example FullTags for the old version to the new one. One thing changed the data were created with transformer V1. and the new app is made with transformer v2

ErhardScampi commented 1 year ago

type Room @model @auth( rules: [ { allow: owner } { allow: public, provider: iam, operations: [read] } { allow: public, operations: [read] } ] ) { id: ID! name: String! description: String image: String xxx: Boolean collectionIds: String order: Int profileId: String @index(name: "byProfileId", queryField: "roomByProfileId") visability: String }

type Collection @model @auth( rules: [ { allow: owner } { allow: public, provider: iam, operations: [read] } { allow: public, operations: [read] } ] ) { id: ID! name: String! uuid: String presentationKinds: [String] items: [ItemInCollection] items_as_json: String description_long: String description_short: String exportTemplate: String url_leadingImage: String visability: String xxx: Boolean profileId: String @index(name: "byProfileId", queryField: "byProfileId") userID: ID! @index(name: "byUser") links_as_json: String order: Int }

type Import @model @auth(rules: [{ allow: owner }]) { id: ID! importDate: String! items: [Item] count: String }

type Item @model @auth( rules: [ { allow: owner } { allow: public, provider: iam, operations: [read] } ] ) { id: ID! title: String uuid: String @index(name: "byUUID", queryField: "itemsByUUID") author: String description_long: String description_short: String resolutions: [String] edition_kind: String edition_data: String licence: String ownLicence: String originalFilename: String! @index(name: "byOriginalFileName", queryField: "itemByOriginalFileName") filename: String! status: String uploaded_year: Int uploaded_month: Int uploaded_day: Int tags: [Tag] path: String! pathSec: String importID: ID! @index(name: "byImport", queryField: "itemsByImport", sortKeyFields: ["id"]) ranking: Int level: String ipfs: String Info: String baseurl: String subItems: [String] kind: String xxx: Boolean userID: String }

type Tag { id: String tagName: String }

type ItemInCollection { id: String url: String title: String author: String description_long: String description_short: String is_leading_image: Boolean resolutions: [String] tags: [Tag] user: String ipfs: String uuid: String profileId: String order: Int treatment: String printDescription: Boolean add_info: String hide_details: Boolean }

type FullTag @model @auth( rules: [ { allow: owner } { allow: public, provider: iam, operations: [read] } ] ) { id: ID! tagName: String! @index(name: "byTagName", queryField: "tagsByName") itemIds: [String] kind: String userID: ID @index(name: "byUser", queryField: "tagsbyProfileId") xxx: Boolean }

type User @model @auth( rules: [ { allow: public, provider: iam, operations: [read] }, { allow: public, operations: [read] }, { allow: owner} ] ) { id: ID! name: String @index(name: "byName", queryField: "userByName") story: String owner: String philosophy: String collections: [Collection] FullTags: [FullTag] tags_as_json: String avartar: String ownNFTPlatforms: String status: String homepage: String searchName: String @index(name: "bySearchName", queryField: "userBySearchName") email: String @index(name: "byEmail", queryField: "userByEmail") cognitoId: String! @index(name: "byCognitoId", queryField: "userByCognitoId") adress: String socialPlatforms: String sex: String callme: String speech: String payment_id: String }

type Event @model @auth( rules: [ { allow: owner } ] ) { id: ID! enventName: String kind: String payload: String userID: String eventYear: Int eventMonth: Int eventDay: Int }

type Query { reorganize(params: String): String @function(name: "reorganize-${env}") myqueryresolver(params: String): String @function(name: "myqueryresolver-${env}") @auth( rules: [ { allow: public, provider: iam } { allow: private provider: iam } ] ) }

ErhardScampi commented 1 year ago

The question is do I have to do some data migration too if I change to transformer V2 ? I checked the data. nor cognitoId in User table nor tagName in FullTag table are null or empty - everything filled. So the error make no sense for me. Ist it possible that arrays of other types are not allowed in transformer 2 somehow ? (the user table has an array of type fullTags, which I think causes the problem.