code: def _serialize_to_one(self, key, val, rlink):
          
  
          data = None
          if val and val['rid']:
              data = {'id': val['rid'], 'type': val['rtype']}
  
          return {
              key: {
                  'data': data,
                  'links': {
                      'related': rlink + '/' + key
                  }
              }
          }
docs: Make a to_one JSON API compliant
  
          :spec:
              jsonapi.org/format/#document-resource-object-relationships
          :param key:
              the string name of the relationship field
          :param val:
              dict containing `rid` & `rtype` keys for the to_one &
              None if the to_one is null
          :return:
              dict as documented in the spec link