Unable to create schema and type

Hello I am trying to create schema with few predicates and a type as mentioned below:

define directives and index

user_name: string @index(term) .
date_created: datetime .
date_modified: datetime .
verified_in: bool .
email_id: string .
contact_no: float .

define types

type user_master {
	user_name
	date_created
	date_modified
	verified_in
	email_id
	contact_no
	creates_post
}

I am facing following error:
Message: while lexing # define directives and index creates_post: [uid] . user_name: string @index(term) . date_created: datetime . date_modified: datetime . verified_in: bool . email_id: string . contact_no: float . # define types type user_master { user_name date_created date_modified verified_in email_id contact_no creates_post } at line 2 column 0: Invalid block: [creates_post]

Raw Error:

{
  "name": "t",
  "url": "http://13.235.61.157:8080/mutate?commitNow=true",
  "errors": [
    {
      "message": "while lexing # define directives and index\ncreates_post: [uid] .\nuser_name: string @index(term) .\ndate_created: datetime .\ndate_modified: datetime .\nverified_in: bool .\nemail_id: string .\ncontact_no: float .\n\n# define types\ntype user_master {\n\tuser_name\n\tdate_created\n\tdate_modified\n\tverified_in\n\temail_id\n\tcontact_no\n\tcreates_post\n} at line 2 column 0: Invalid block: [creates_post]",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

Any idea if there is a syntactical issue?

Hi @moditej, have you defined type of creates_post?

1 Like

Hello @Naman , I did define it. I believe someone edited the post and clipped the first line where it was defined. I will put the entire mutate block here:

define directives and index

creates_post: [uid] .
user_name: string @index(term) .
date_created: datetime .
date_modified: datetime .
verified_in: bool .
email_id: string .
contact_no: float .

define types

type user_master {
user_name
date_created
date_modified
verified_in
email_id
contact_no
creates_post
}

I suppose you are defining types in mutate tab of ratel.
For schema insertion just go to schema tab and do bulk insertion in ratel.

1 Like

This works. But have a doubt. I specifically remember doing it through mutate tab on my local machine. Was there an update which changed this behaviour?

I don’t think pushing schema from mutating tab was there. Need to check. But you can directly mutate data and dgraph will generate schema for you.