When you need to seed a GraphQL API or import a spreadsheet of records, writing one mutation per row by hand is slow. This tool reads your CSV and emits a GraphQL document with one createX call per row, inferring the right scalar type for every value — so strings are quoted, numbers and booleans are bare, and empty cells become null.
How it works
- Parse the CSV with an RFC 4180 parser that respects quoted fields containing commas, newlines and escaped
""quotes. The first row supplies the field names. - Infer each value’s type so the GraphQL is syntactically correct:
- empty →
null true/false(case-insensitive) → boolean- a finite number → numeric literal
- anything else → a double-quoted string, with
"and\escaped
- empty →
- Emit the mutation. Each row becomes
mutationField(arg1: value1, arg2: value2) { id }. You can output one operation per row, or alias all rows into a single document (row0: createUser(...) { id }) so the batch runs in one request.
mutation Seed {
row0: createUser(name: "Ada", age: 36, active: true) { id }
row1: createUser(name: "Linus", age: 54, active: false) { id }
}
Tips and notes
- Header names are used verbatim as argument names — make sure they match your schema’s input fields (or rename the CSV header row).
- Quote a numeric-looking value in the CSV (e.g. a postcode or phone number) by wrapping it in
"…"if you want it kept as a string; otherwise it is inferred as a number. - The selection set defaults to
{ id }; change it after generation if your mutation returns a different shape. - Everything runs locally, so the CSV’s contents stay on your device.