I am looking to store Kubernetes YAML/JSONs in dgraph. The issue is sometimes fields with same name (predicate in dgraph) have int or string data. Example:
In Kubernetes, which uses openapi v3, this field will defined using anyOf.
targetPort:
anyOf:
- type: integer
- type: string
description: Name or number of the port to access on
the container. Number must be in the range 1 to 65535.
Name must be an IANA_SVC_NAME.
x-kubernetes-int-or-string: true
Will it be possible to store this types of JSONs in dgraph?
Dgraph would not consider the type to be of “string” by default in case of predicate having different types of values. I apologize for the previous information. It would infer the type based on the value of the predicate. So mutation like this would throw an error.
That is unfortunate given how dgraph handles all predicates in a Global namespace. Now 2 different JSON objects can’t have fields with same name but different datatype.