     1	import { RestApiResourceError } from '../../../lib/rest-api-errors.js'
     2	import { findRelationshipDefinition } from './common.js'
     3	import { buildRelationshipUrl } from '../lib/querying/url-helpers.js'
     4	
     5	/**
     6	 * GET RELATIONSHIP
     7	 * Retrieves relationship linkage data (just resource identifiers)
     8	 * GET /api/articles/1/relationships/author
     9	 *
    10	 * @param {string} id - The ID of the resource
    11	 * @param {string} relationshipName - The name of the relationship
    12	 * @returns {Promise<object>} Relationship linkage with links
    13	 */
    14	export default async function getRelationshipMethod ({ params, context, vars, helpers, scope, scopes, runHooks, scopeName, api }) {
    15	  context.method = 'getRelationship'
    16	  context.id = params.id
    17	  context.relationshipName = params.relationshipName
    18	  context.schemaInfo = scopes[scopeName].vars.schemaInfo
    19	
    20	  // Validate the relationship exists
    21	  const relDef = findRelationshipDefinition(context.schemaInfo, context.relationshipName)
    22	
    23	  if (!relDef) {
    24	    throw new RestApiResourceError(
    25	      `Relationship '${context.relationshipName}' not found on resource '${scopeName}'`,
    26	      { subtype: 'relationship_not_found' }
    27	    )
    28	  }
    29	
    30	  // Check permissions
    31	  await runHooks('checkPermissions')
    32	  await runHooks('checkPermissionsGetRelationship')
    33	
    34	  // Reuse existing get method with minimal fields
    35	  const fullRecord = await scope.get({
    36	    id: context.id,
    37	    queryParams: {
    38	      include: [context.relationshipName],
    39	      fields: { [scopeName]: vars.idProperty || 'id' }
    40	    },
    41	    transaction: context.transaction,
    42	    simplified: false,
    43	    isTransport: params.isTransport
    44	  })
    45	
    46	  if (!fullRecord || !fullRecord.data) {
    47	    throw new RestApiResourceError('Resource not found', { subtype: 'not_found' })
    48	  }
    49	
    50	  // Extract just the relationship data
    51	  const relationshipData = fullRecord.data.relationships?.[context.relationshipName]
    52	
    53	  // Build response with links
    54	  return {
    55	    links: {
    56	      self: buildRelationshipUrl(context, scope, scopeName, context.id, context.relationshipName, true),
    57	      related: buildRelationshipUrl(context, scope, scopeName, context.id, context.relationshipName, false)
    58	    },
    59	    data: relationshipData?.data || (relDef.type === 'hasMany' || relDef.type === 'manyToMany' ? [] : null)
    60	  }
    61	};
