It looks like you’re mixing DQL and GraphQL?
This is a GraphQL type:
type Username {
username: String! @id
}
This looks like a DQL statement to update the graph schema.
username: string @index(term, fulltext) @upsert @count .
@id is a GraphQL directive. When you add a GraphQL schema to the database, it converts it into a graph schema. I believe it just gets converted to a string predicate with upsert set to true.
When you add a GraphQL type to the database schema, Dgraph represents this in the graph with a <dgraph.type> predicate(field) on the nodes, and when you save a new instance of a type it’ll save the name of the type to the <dgraph.type> predicate (field).
If you’re using GraphQL, you should save your GraphQL schema in a file, e.g. schema.graphql. To add your updated schema to the database, you can use this command:
curl -X POST localhost:8080/admin/schema --data-binary '@src/lib/graphql/schema.graphql'
The @ is important. Just replace with the path to your schema file.
If there are no errors you should see the following:
❯ curl -X POST localhost:8080/admin/schema --data-binary '@src/lib/graphql/schema.graphql'
{"data":{"code":"Success","message":"Done"}}%