Search code examples
graphqlgraphcool

A relation in graphcool makes fail the deploy for no reason


I created this relation in my graphcool

 type User @model {
   id: ID! @isUnique
   location: Location! @relation(name: "UserLocation")
  }

 type Location @model {
   id: ID! @isUnique
   lat: Int
   lng: Int
   User: User! @relation(name: "UserLocation”)
 }

Before location was a String, but now I wanted it to be an object so I created this relation, so that I can then use nested mutations. When I deploy I get this error:

There are issues with the new service definition:

Global
  ✖ None.get

I googled, looked on the documentation but I cannot understand what I am doing wrong, is a simple relation.


Solution

  • Faced issues like this when changing the type of fields as well. Not sure what the reason for this behavior (looks like it's a graphcool issue) but to solve them you can split it into two steps:

    1) remove this relation from graphcool schema:

    type User @model {
       id: ID! @isUnique
       # location: Location! @relation(name: "UserLocation")
      }
    
     type Location @model {
       id: ID! @isUnique
       lat: Int
       lng: Int
       # User: User! @relation(name: "UserLocation”)
     }
    

    2) revert relation fields with the new type:

    type User @model {
       id: ID! @isUnique
       location: Location! @relation(name: "UserLocation")
      }
    
     type Location @model {
       id: ID! @isUnique
       lat: Int
       lng: Int
       User: User! @relation(name: "UserLocation”)
     }