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
}
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> {
Characters.Description
}
type <dgraph.graphql> {
dgraph.graphql.schema
dgraph.graphql.xid
}
I’m new to DGraph and DQL, can you please help me with a code example?
Edit
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.
@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 {
studentId
name
}
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.