     1	/**
     2	 * PATCH RELATIONSHIP
     3	 * Completely replaces a relationship
     4	 * PATCH /api/articles/1/relationships/author
     5	 *
     6	 * @param {string} id - The ID of the resource
     7	 * @param {string} relationshipName - The name of the relationship
     8	 * @param {object|array} relationshipData - New relationship data
     9	 * @returns {Promise<void>} 204 No Content
    10	 */
    11	export default async function patchRelationshipMethod ({ params, context, vars, helpers, scope, scopes, runHooks, scopeName, api }) {
    12	  context.method = 'patchRelationship'
    13	  context.id = params.id
    14	  context.relationshipName = params.relationshipName
    15	
    16	  // Transaction handling
    17	  context.transaction = params.transaction ||
    18	    (helpers.newTransaction && !params.transaction ? await helpers.newTransaction() : null)
    19	  context.shouldCommit = !params.transaction && !!context.transaction
    20	  context.db = context.transaction || api.knex.instance
    21	
    22	  try {
    23	    // Check permissions
    24	    await runHooks('checkPermissions')
    25	    await runHooks('checkPermissionsPatchRelationship')
    26	
    27	    // Reuse existing patch with relationship data
    28	    await scope.patch({
    29	      id: context.id,
    30	      inputRecord: {
    31	        data: {
    32	          type: scopeName,
    33	          id: context.id,
    34	          relationships: {
    35	            [params.relationshipName]: { data: params.relationshipData }
    36	          }
    37	        }
    38	      },
    39	      transaction: context.transaction,
    40	      simplified: false,
    41	      isTransport: params.isTransport
    42	    })
    43	
    44	    await runHooks('finish')
    45	    await runHooks('finishPatchRelationship')
    46	
    47	    if (context.shouldCommit) {
    48	      await context.transaction.commit()
    49	    }
    50	
    51	    // 204 No Content
    52	  } catch (error) {
    53	    await handleWriteMethodError(error, context, 'PATCH_RELATIONSHIP', scopeName, log)
    54	  }
    55	}
