SQL migration tool: GraphQL types not generated on Slash

I used the SQL migration tool on my MySQL database and obtained this schema:

Works.Date: int .
Works.LongTitle: string .
Works.ShortTitle: string .
Works.Source: string .
Works.Title: string .
Works.TotalParagraphs: int .
Works.TotalWords: int .
Works.WorkID: string .
Works.GenreType: [uid] .
Chapters.Chapter: int .
Chapters.ChapterID: int .
Chapters.Description: string .
Chapters.Section: int .
Chapters.WorkID: [uid] .
Characters.Abbrev: string .
Characters.CharID: string .
Characters.CharName: string .
Characters.Description: string .
Characters.SpeechCount: int .
Characters.Works: string .
Genres.GenreName: string .
Genres.GenreType: string .
Paragraphs.Chapter: int .
Paragraphs.CharCount: int .
Paragraphs.ParagraphID: int .
Paragraphs.ParagraphNum: int .
Paragraphs.ParagraphType: string .
Paragraphs.PhoneticText: string .
Paragraphs.PlainText: string .
Paragraphs.Section: int .
Paragraphs.StemText: string .
Paragraphs.WordCount: int .
Paragraphs.WorkID: [uid] .
Paragraphs.CharID: [uid] .
Quotations.Location: string .
Quotations.QuotationID: int .
Quotations.QuotationText: string .

I expected that regular GraphQL types will get generated in Slash once the schema and data is uploaded. Something like this (incomplete, only for representation):

type Chapters {
    chapterID: ID
    description: String
    work: Works

type Works {
    workID: ID
    description: String

However this didn’t happen. I see a blank schema on Slash, and can’t execute GraphQL queries there.

The live loader had run successfully and 3000 credits were deducted.The RDF format predicates are visible on play.dgraph.io.

What should be done so that GraphQL types are generated and I can run queries and mutations from Slash? For my use case, I wish to stick to regular GraphQL.

If you already have your data loaded then all you need to do is create your graphql schema in Slash using the types you already defined.

I am hoping you imported you data with a <dgraph.type> predicate.

FYI, the graphql schema is not created when using bulk loader or live loader, you have to create the graphql schema separately. It is usually advised to create the GraphQL schema first then load the data if you are using the live loader.

@amaster507 how can I convert the RDF predicates to GraphQL types? I added this type in Slash but I’m getting an empty value on querying:

type Characters {
    Description: String

No result on querying for characters

There’s no <dgraph.type> in the generated sql.rdf and schema.txt files. But it’s visible in Ratel’s bulk edit menu. Also type <Characters> showed up in Ratel after I added this type in Slash.

<Characters.Abbrev>: string .
<Characters.CharID>: string .
<Characters.CharName>: string .
<Characters.Description>: string .
<Characters.SpeechCount>: int .

type <Characters> {
type <dgraph.graphql> {

I’m new to DGraph and DQL, can you please help me with a code example?


Trying to get your solution working on a smaller dataset, but without success. Here’s some sample data, please help me get the schema right so I can replicate it on my dataset.

_:Student.1 <Student.studentId> "1" .
_:Student.1 <Student.name> "Jack" .
_:Student.2 <Student.studentId> "2" .
_:Student.2 <Student.name> "John" .

I tried these 2 methods

  1. Created this schema on Slash, then live loaded the data. Queries return empty result.
type Student {
    studentId: ID
    name: String
  1. Added Student type in schema.txt, then pushed it to Slash. Schema does not show up in Slash.
type Student {

studentId: string .
name: string .

@pawan can you drop some hints?

Hi @secretshardul
If you are trying to set an external ID, please use the schema as below.

type Student {
    studentId: String! @id
    name: String

You need to add types to your mutation (as Anthony mentioned) as below. I added this through a Ratel mutation on a slash endpoint.

    _:Student.1 <Student.studentId> "1" .
    _:Student.1 <Student.name> "Jack" .
    _:Student.1 <dgraph.type> "Student" .
    _:Student.2 <Student.studentId> "2" .
    _:Student.2 <Student.name> "John" .
    _:Student.2 <dgraph.type> "Student" .    

Finally, you can query through Slash API Explorer.

query MyQuery {
  getStudent(studentId: "1") {

The result is as below.

  "data": {
    "getStudent": {
      "name": "Jack"
1 Like

@anand thanks for helping out, the issue has been resolved. But have a question regarding the schema.txt generated by the SQL migration tool.

The schema in this file is in RDF format, similar to that added in Ratel. On the other hand, schema fed into Slash is pure GraphQL. I wonder if there’s a way to feed schema.txt using live loader and see the GraphQL schema in slash.

I tried this schema using live loader, but it didn’t work. The type appeared in Ratel though.

studentId: String! @id .
name: String .

type Student {

No there is not a way to do that. GraphQL schema will generate DQL schema, but a DQL schema will not generate GraphQL schema. There are many variables in the mix where users have to make decisions in the GraphQL schema to get formulate the correct queries and mutations. It is not possible at the moment to make those decisions for the user.

1 Like

@amaster507 found a way to automate adding <dgraph.type> with regular expression. Check out this post SQL migration tool: shenanigans and solutions

Let <Character.charId> be the table ID. We wish to add <dgraph.type> "Character" for every character.

In VS Code, regex search for (.*?) <Character.charId> (.*?) . and replace with

$1 <Character.charId> $2 .
$1 <dgraph.type> "Character" .

This gives us

_:Character.1citizen <Character.charId> "1citizen" .
_:Character.1citizen <dgraph.type> "Character" .