Forum Discussion
GraphQL update... mutation for Fabric SQL DB failing
Hi everybody,
I want to update items in a Fabric SQL DB via GraphQL mutation query. But that fails with "InternalServerError" (and nothing else).
What I tried:
- ❌ mutation update....
- ✅ mutation create...
- ✅ mutation delete...
✅ (directly in the SQL DB): UPDATE dbo.product SET product_name = 'CHANGED' WHERE ROWID = '<UUID>'
Did someone else here experience something similar? Is this a defect 🐞 in the GraphQL API / Fabric SQL DB / their combination?
What was your solution? (And what was the issue exactly?)
A workaround might be to create a stored proc and let that do the update. I'd prefer to be able to use a working update mutation though. So
Any help highly appreciated! <3 --> Snippets below
Best
Martin
(Snippets stripped down for readability)
The failing mutation:
mutation {
updateproduct (
ROWID: "<UUID>",
item: {
product_name: "CHANGED"
})
{
ROWID product_name
}
}
//// Definitions from the GraphQL schema:
"""Updates a product"""
updateproduct (
"""The ID of the item being updated."""
ROWID: UUID!
"""Input representing all the fields for updating product"""
item: UpdateproductInput!
): product
"""Input type for updating product_mapping"""
input UpdateproductInput {
"""Input for field ROWID on type UpdateproductInput"""
ROWID: UUID
"""Input for field product_name on type UpdateproductInput"""
product_name: String
}The table in Fabric SQL DB (as by "Script as create")
CREATE TABLE [dbo].[product](
[ROWID] [uniqueidentifier] NOT NULL,
[product_name] [nvarchar](255) NOT NULL,
) ON [PRIMARY]
ALTER TABLE [dbo].[product_mapping]
ADD PRIMARY KEY CLUSTERED (
[ROWID] ASC
) WITH ( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ONLINE = OFF, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
ON [PRIMARY]
ALTER TABLE [dbo].[product_mapping]
ADD DEFAULT (newsequentialid()) FOR [ROWID]
8 Replies
- v-achippaCommunity Support
Hi msturzen,
Thank you for reaching out to Microsoft Fabric Community.
Thank you ipkus for the prompt response.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa- msturzenFrequent Visitor
Dear v-achippa,
to me there is no solution yet. All I have is a workaround for something - update of a single row in a SQL DB - that should just work out of the box. Don't get me wrong: I am thankful for the workaround.
At least - if there is some known product limitation - that should be documented in Fabric's GraphQL API documentation
Thanks
Martin
- msturzenFrequent Visitor
Thanks again,
I will try to work from your sample but thath might take a few days....Will come back asap
Best
Martin - ipkusFrequent Visitor
I understand your frustration. Yes, querying part works well
The error have been very cryptic in Fabric. Give below a try
- Import a table ( only having mutations can cause issues )
- Create a test procedure with the output columns same as input and add additional return values as needed.
- Import that procedure into Graph QL
- This method works well. Once this works for you, you can tweak and play around with settings
- ipkusFrequent Visitor
Yes, GraphQL can be slightly sensitive when it comes to mutations. We have been able to implement several mutations via strored procdures.
Looks like your mutation has gotten classified as a write-only (Mutation). This means it doesn't produce a Query node. GraphQL schema generation requires at least one Query field by spec — without it, schema validation fails. In the absence of a Query field, schema validation cannot be completed successfully.
Also, make sure Referenced tables are present and accessible in the underlying data source. If the required tables are unavailable, the stored procedure may fail and return a SQL error.
- msturzenFrequent Visitor
Thank you so much for your reply ipkus. and confirming using a stored procedure is a way to enable updates.
Regarding your other statements:- What do mean by "slightly sensitive"? Is it pure luck for mutations work? Do I have to roll a D20? (sorry for being grumpy here, not your fault)
- Is there anything I can do to get rid of that write-only classification?
- Querying the resource works just fine --> (naive) conclusio: Seems not be write-only
- What is a Query field? ROWID, other fields of the resource?
- Thanks for hinting at availability of Referenced tables. In my case there no references.
- Unfortunately I do not see any SQL error in the response and Fabric SQL DB is very limited wrt monitoring. Any ideas for this?