Open zachegnermh opened 1 year ago
Hi @zachegnermh 👋 thanks for raising this issue! What version of the Amplify CLI were you using when the graphql mutations were generated? I just tried generating the mutations with the last version of the CLI and given schema but my createDashboard
mutation looks different to yours.
export const createDashboard = /* GraphQL */ `
mutation CreateDashboard(
$input: CreateDashboardInput!
$condition: ModelDashboardConditionInput
) {
createDashboard(input: $input, condition: $condition) {
id
title
reports {
nextToken
startedAt
}
channelId
createdAt
updatedAt
_version
_deleted
_lastChangedAt
}
}
`;
I was able to successfully create a Dashboard record
Can you try upgrading to the latest version of the Amplify CLI if not already on that version and re-running amplify codegen
?
Hi @chrisbonifacio, thanks for looking into this issue. I had noticed that I was running Amplify CLI version 10.6.2, so I upgraded today to 10.8.1. I erased mock data and reran amplify mock api as well as amplify codegen. I am still facing the same error as before when trying to "createDashboard" and my mutations file has not changed.
export const createDashboard = /* GraphQL */
mutation CreateDashboard(
$input: CreateDashboardInput!
$condition: ModelDashboardConditionInput
) {
createDashboard(input: $input, condition: $condition) {
id
title
reports {
items {
id
reportID
dashboardID
createdAt
updatedAt
}
nextToken
}
channelId
createdAt
updatedAt
}
}
;
@zachegnermh Of course :) Maybe our codegens are configured differently. Can you share your graphqlconfig.yml
file?
This is mine for comparison:
projects:
dsnext13:
schemaPath: amplify/backend/api/dsnext13/build/schema.graphql
includes:
- src/graphql/**/*.ts
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: typescript
generatedFileName: src/API.ts
docsFilePath: src/graphql
maxDepth: 2
extensions:
amplify:
version: 3
Might be that your max depth is configured a bit higher. I tried increasing it and codegen is now my mutation looks more like yours.
EDIT: I wasn't using mock but even with a higher max depth and mock, I'm still able to create Dashboards 🤔
Thought maybe linking to a channel might cause the issue but I was also able to create a Dashboard
linked to a Channel
I noticed some other small differences between our generated mutations. Our id fields are generated differently in the mutation selection set:
yours (reportID
and dashboardID
vs channelId
) perhaps this has something to do with the issue?
createDashboard(input: $input, condition: $condition) {
id
title
reports {
items {
id
reportID
dashboardID
}
}
channelId # why is this one different to the others?
}
mine (all formatted as Id
)
createDashboard(input: $input, condition: $condition) {
id
title
reports {
items {
id
dashboardId
reportId
}
}
channelId
}
}
@chrisbonifacio, here is my graphqlconfig.yml
, maxDepth
isn't set here.
projects:
mrms:
schemaPath: amplify/backend/api/mrms/build/schema.graphql
includes:
- src/graphql/**/*.js
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: javascript
generatedFileName: ''
docsFilePath: src/graphql
extensions:
amplify:
version: 3
As to the reportID
and dashboardID
, I am not sure where this is coming from. The only instances of this in my code are in the autogenerated graphQL files.
I am also facing the same error in graphiQL
Here's is trying with reportId
and dashboardId
And also without querying reportID
or dashboardID
Hi @zachegnermh apologies for the delay. I still haven't been able to reproduce this issue. Have you tried setting the maxDepth in your graphqlconfig.yml
? You can do this by running amplify codegen configure
Does this error still occur when running the same mutation the AppSync console?
I would also try adjusting the selection set to
createDashboard(input: $input, condition: $condition) {
id
title
reports {
items {
id
reportID
dashboardID
channelId
}
}
channelId # why is this one different to the others?
}
Hi @chrisbonifacio, I tried setting maxDepth
to 4, but there was no difference in outcome. Still receiving the same error. Also, when trying the selection set you have provided, I receive this "Cannot query field \"channelId\" on type \"DashboardReports\"."
.
Very strange behavior, because even though I am receiving an error on create, some of the items were actually created on the DB. However, when trying to run a getDashboard
or updateDashboard
, I still get: {data: {…}, errors: Array(1)} data : {getDashboard: {…}} errors : Array(1) 0 : data : null errorInfo : null errorType : "DynamoDB:ValidationException" locations : [{…}] message : "The table does not have the specified index: byChannel" path : (2) ['getDashboard', 'reports']
I'm still unsure as to why my reportID
and dashboardID
are showing uppercase ID
, as I haven't changed the schema since the one I have provided to you at the top.
@zachegnermh apologies for the delay. Can you share the contents of your amplify/cli.json
file? I'd like to compare the feature flags that we have enabled/disabled.
Also, please run amplify diagnose --send-report
and share the output project identifier id.
@chrisbonifacio No worries!
Project Identifier: 686f8d7fabdbbdcdf584a874e1f2007d
Here's the cli.json
{
"features": {
"graphqltransformer": {
"addmissingownerfields": true,
"improvepluralization": false,
"validatetypenamereservedwords": true,
"useexperimentalpipelinedtransformer": true,
"enableiterativegsiupdates": true,
"secondarykeyasgsi": true,
"skipoverridemutationinputtypes": true,
"transformerversion": 2,
"suppressschemamigrationprompt": true,
"securityenhancementnotification": false,
"showfieldauthnotification": false,
"usesubusernamefordefaultidentityclaim": true,
"usefieldnameforprimarykeyconnectionfield": false,
"enableautoindexquerynames": false,
"respectprimarykeyattributesonconnectionfield": false,
"shoulddeepmergedirectiveconfigdefaults": false,
"populateownerfieldforstaticgroupauth": false
},
"frontend-ios": {
"enablexcodeintegration": true
},
"auth": {
"enablecaseinsensitivity": true,
"useinclusiveterminology": true,
"breakcirculardependency": true,
"forcealiasattributes": false,
"useenabledmfas": true
},
"codegen": {
"useappsyncmodelgenplugin": true,
"usedocsgeneratorplugin": true,
"usetypesgeneratorplugin": true,
"cleangeneratedmodelsdirectory": true,
"retaincasestyle": true,
"addtimestampfields": true,
"handlelistnullabilitytransparently": true,
"emitauthprovider": true,
"generateindexrules": true,
"enabledartnullsafety": true
},
"appsync": {
"generategraphqlpermissions": true
},
"latestregionsupport": {
"pinpoint": 1,
"translate": 1,
"transcribe": 1,
"rekognition": 1,
"textract": 1,
"comprehend": 1
},
"project": {
"overrides": true
}
},
"debug": {
"shareProjectConfig": true
}
}
Hi @chrisbonifacio ,
I hope this message finds you well. I just wanted to check in and see if there has been any progress made on this bug. If you need any further information or assistance from me, please let me know. I understand you may have a busy schedule, so I appreciate any update you can provide.
Thank You, @zachegnermh
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
GraphQL API
Amplify Categories
auth, api, hosting
Environment information
Describe the bug
After creating a manyToMany relationship between two Dashboards and Reports in graphql schema; a simple createDashboard request returns a DynamoDB:Validation Exception.
The message returned is "The Table does not have the specified index: byChannel"
I notice if I omit the reports from the mutation query, I do not receive error. Since I am using a manyToMany relationship between Reports and Dashboards, Reports is still being queried on createDashboard. The problem lies somewhere with the hasMany relationship that Channels has with Reports and Dashboards.
i.e. This works:
Automatic query from amplify, does NOT work:
Expected behavior
The createDashboard mutation is run and a dashboard is created with basic info(i.e. id, title) in preparation for a @manyToMany link with "Reports" using createDashboardReports.
Reproduction steps
1.) run a createDashboard mutation using the provided schema.
Code Snippet
The schema looks like this:
addDashboard method:
Error Log from graphQL
Log output
aws-exports.js
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