Can I specify a custom field as the unique field like uid，but it store UUID value
No, you can’t. In Dgraph only UID will work natively. You can use UUID if you want. For indexation, use Hash.
If you’re happy and able to generate your UUID outside of Dgraph, you could do that and use the @id directive on the schema definition.
Note: This will still store UIDs as well for each node, since that’s what’s used internally.
I tried it just now，the hash indexation can‘t guarantee entity is unique，I created duplicate entities。。Is there any other way？
My project uses DDD for modeling，the entity identifier needs to be specified before persist。the dgraph uid seem doesn’t fit my scene
^ only if using the GraphQL API endpoint. This is not in the underlying DQL schema. I think OP is looking for DQL solution not an API solution FWIW.
Right, there is no guarentee of uniqueness at the DQL level even if uniqueness is applied in the GraphQL API.
Your only solution to guarantee uniqueness outside of the uid is to use an API (either the GraphQL API or a custom layer) and limit DQL access
Yes, as it is just an index. What can guarantee uniqueness is managing a method. Use Upsert directive(not mandatory) and Upsert Block. That’s a second level to master DQL. The hash will make things faster during the upsert.