typescript-client icon indicating copy to clipboard operation
typescript-client copied to clipboard

422 error on creating classes with references: invalid dataType: reference property to nonexistent class

Open amirhouieh opened this issue 2 years ago • 3 comments
trafficstars

I am trying to build something similar to the Wikipedia example in typescript and node. It seems in the npm client, there is no create schema method, and hence I have to create classes async in different API calls, but in doing so I get 422 error: invalid dataType: reference property to a nonexistent class. I am not sure if this is the cause of the problem or something else.

  • There was a related conversation on Weaviate Slack, suggesting changing vectorizier would make it work (for example text2vec-transformers do not work but text2vec-contextionary does. In my case none works.
const schemaClasses = [
   ArticleClass,
   ParagraphClass
]

for await (classObj in schemaClasses){
   await client.schema.classCreator().withClass(classObj)
}

amirhouieh avatar Apr 14 '23 09:04 amirhouieh

I have the same issue. It's driving me crazy. Tried many different approaches like adding classes first, then properties for each class that reference other classes in separate API calls. Example log from Docker: {"action":"graphql_rebuild","level":"warning","msg":"ignoring ref prop "topConceptOf" on class "Concept", because it contains reference to nonexistent class ["ConceptScheme"]","time":"2023-05-30T17:34:52Z"}. Using Weaviate 1.19.6

ElvinD avatar May 30 '23 17:05 ElvinD

Hi both @amirhouieh and @ElvinD, can the issue that you're both observing be summarised as so:

  • You have classes that depend on one another through their property definitions
  • You are looping through the classes in a flat manner and sending async requests
  • As such, there is no guarantee the classes are created in the correct order to be referenced successfully

If this is the case, might using promise chaining with the current classCreator() API fix your issue? So something like:

const createClass(classObj) => client.schema
  .classCreator()
  .withClass(classObj)
  .do();
await createClass(ParentClass)
  .then(async () => await createClass(ChildClass))

P.S. If your classes circularly reference one another then this above method won't work. The Python client is capable of this as shown here but I believe that the TypeScript client currently lacks this same functionality.

tsmith023 avatar Jun 21 '23 15:06 tsmith023

I'm having the same issue on python's weaviate client

schemas = prepare_weaviate_schemas(...)
client.schema.create({"classes": schemas})

The schemas list contains the classes [Article, Author] for example, one of the authors props references the article, so the order is ok within the list.

touatiosema avatar Jul 10 '24 10:07 touatiosema