How do I feed a generated schema.graphql into Slash GraphQL?

How do I feed the generated schema.txt and sql.rdf into Slash GraphQL? The live loader command for localhost is not working in my case:

dgraph live -z localhost:5080 -a localhost:9080 --files sql.rdf --format=rdf --schema schema.txt

@secretshardul You can see the steps to run live loader for Slash GraphQL here: https://dgraph.io/docs/slash-graphql/admin/import-export/#importing-data-with-live-loader. You’ll need to use the gRPC endpoint and provide your API token in live loader. You can then run your queries over HTTP or gRPC: https://dgraph.io/docs/slash-graphql/advanced-queries/#connecting-from-dgraph-clients

1 Like

Got the live loader working with Slash. But after uploading data, Slash is showing an empty schema.

However the predicates and schema are visible on Ratel (play.dgraph.io). But no types are generated here as well.

I want to run regular GraphQL queries on my data from Slash. For that I had expected GraphQL types to be generated in the following format:

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

type Works {
    workID: ID
    description: String
}

Instead, I’m seeing the schema in RDF format on Ratel.

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] .

How can I obtain regular GraphQL types from by converted data :thinking:?

PS: Can you please upgrade my forum account? I unable to upload more than 1 image.

I used the SQL to DGraph migration tool to generate schema.txt and sql.rdf files from a MySQL database. The tutorial explains how to import this data into a DGraph instance running on localhost:

dgraph live -z localhost:5080 -a localhost:9080 --files sql.rdf --format=rdf --schema schema.txt

I tried replacing localhost:5080 and localhost:9080 with my https://example.com/graphql endpoint without success.

There’s another tutorial on importing data into Slash using live loader. It uses this command:

docker run -it --rm -v /path/to/g01.json.gz:/tmp/g01.json.gz dgraph/dgraph:v20.07-slash \
  dgraph live --slash_grpc_endpoint=<grpc-endpoint>:443 -f /tmp/g01.json.gz -t <api-token>

I’m quite confused here. Here JSON data is uploaded while schema and rdf is not mentioned. How do I upload the generated schema.txt and sql.rdf to Slash GraphQL?

Edit

Issue resolved, please look at this answer.

I split the original topic from a commentt of a blog post to its own thread, then merged another duplicate content into this thread.

Instead of using Ratel, you can use any standard GraphQL tool like GraphQL Playground or GraphiQL to query your data via GraphQL. The schema that your GraphQL schema generates maps internally to the Dgraph schema following the mapping described in the “Mapping GraphQL to a Dgraph schema” docs: https://dgraph.io/docs/graphql/dgraph/.

When using Dgraph Live Loader, you can specify JSON or RDF data via the -f/--files flag and optionally a schema via the -s/--schema flag. Your JSON/RDF data loaded via live loader should match the mapping rules linked earlier. Otherwise, you can use GraphQL mutations to load your data into your Slash backend.