Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply

Fabric GraphQl - How to create multiple record under single mutation.

I am working on GraphQl In fabric. I am having a table which conatins 5 records. I want to create more twomore records in table. When I am tring below query getting some error. 

Sakshi_Khojare_0-1738559854504.png

 





For ex - In sql 
INSERT INTO Student (ROLL_NO, NAME, ADDRESS, PHONE, AGE) VALUES
(1, 'Ram', 'Delhi', 'XXXXXXXXXX', 18),
(2, 'Ramesh', 'Gurgaon', 'XXXXXXXXXX', 18),


How can we achive this in Graph QL ?

1 ACCEPTED SOLUTION

Hello @Sakshi_Khojare 


I have created a new WH called Graphql_test and created one table 

MyTable and 
ALTER TABLE MyTable
ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED (ID) NOT ENFORCED;

nilendraFabric_0-1738679482972.png
It was empty table .

I added it to graphql api 
and use muttation to add two records, it worked

 

nilendraFabric_1-1738679588028.png



Please see if this is helpful

 

View solution in original post

10 REPLIES 10
nilendraFabric
Solution Supplier
Solution Supplier

hello @Sakshi_Khojare 

 

there are two things which I want to emphasise 

 

Primary key constraints (even `NOT ENFORCED`) are required for mutations, but these only enable single-row operations.
• Bulk operations aren’t listed as supported in Microsoft’s GraphQL API FAQ

 

Try this instead

 

mutation {
createStudent1: createStudent(item: {ROLL_NO: 1, NAME: "Ram", ...}) { result }
createStudent2: createStudent(item: {ROLL_NO: 2, NAME: "Ramesh", ...}) { result }
}

 

 

or you can explore stored proc approach for bulk inserts

 

something like this

 

CREATE PROCEDURE BulkBatchInsert
AS
BEGIN
BULK INSERT StagingStudents FROM 'data.csv' WITH (BATCHSIZE=100000);
INSERT INTO Students SELECT * FROM StagingStudents;
END;

 

please give it a try and let us know

 

thanks

Hi @nilendraFabric,
Thanks for your quick respone.
I tried the above query but still unable to solve my issue. Below is the snapshot attched. Can you plz help me with this. 

Sakshi_Khojare_0-1738571291204.png

 

You might have to change the syntax like this

 

mutation {
createempinfo1: createempinfo(item: {Id: 30, Name: "Rohan", Address: "Amravati"}) {
result
}
createempinfo2: createempinfo(item: {Id: 31, Name: "Raj", Address: "Nagpur"}) {
result
}
}

Sakshi_Khojare_0-1738573104335.png

can you help me in this ?

 

There can be multiple reasons 

 Ensure pk is still valid

 

do try this

 

ALTER TABLE YourTable ADD CONSTRAINT PK_YourTable PRIMARY KEY NONCLUSTERED (Id) NOT ENFORCED;

 

And then try

 

mutation {
createempinfo1: createempinfo(item: {Id: 30, Name: "Rohan", Address: "Amravati"}) {
Id
Name
Address
}
createempinfo2: createempinfo(item: {Id: 31, Name: "Raj", Address: "Nagpur"}) {
Id
Name
Address
}
}

Try to change the keys as well

Unable to the first query which you had shared.

Sakshi_Khojare_0-1738575337192.png

 

Try to run it in warehouse

We had ID column as PK already.

Hello @Sakshi_Khojare 


I have created a new WH called Graphql_test and created one table 

MyTable and 
ALTER TABLE MyTable
ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED (ID) NOT ENFORCED;

nilendraFabric_0-1738679482972.png
It was empty table .

I added it to graphql api 
and use muttation to add two records, it worked

 

nilendraFabric_1-1738679588028.png



Please see if this is helpful

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

JanFabricDE_carousel

Fabric Monthly Update - January 2025

Explore the power of Python Notebooks in Fabric!

JanFabricDW_carousel

Fabric Monthly Update - January 2025

Unlock the latest Fabric Data Warehouse upgrades!

JanFabricDF_carousel

Fabric Monthly Update - January 2025

Take your data replication to the next level with Fabric's latest updates!