import { ObjectValueNode } from "graphql/language" ; import { Algebra } from "sparqlalgebrajs" ; import { IConvertContext } from "../../IConvertContext" ; import { IConvertSettings } from "../../IConvertSettings" ; import { Util } from "../../Util" ; import { IValueNodeHandlerOutput , NodeValueHandlerAdapter } from "./NodeValueHandlerAdapter" ; /**
 * Converts GraphQL objects to triple patterns by converting keys to predicates and values to objects.
 */ export class NodeValueHandlerObject extends NodeValueHandlerAdapter < ObjectValueNode > { constructor ( util , settings ) { super ( 'ObjectValue' , util , settings ) ; } public handle ( valueNode , fieldName , convertContext ) { const subject = this . util . dataFactory . blankNode ( ) ; let auxiliaryObjectPatterns = [ ] ; for ( const field of valueNode . fields ) { const subValue = this . util . handleNodeValue ( field . value , fieldName , convertContext ) ; for ( const term of subValue . terms ) { auxiliaryObjectPatterns . push ( this . util . createQuadPattern ( subject , field . name , term , convertContext . graph , convertContext . context ) ) ; } if ( subValue . auxiliaryPatterns ) { auxiliaryObjectPatterns = auxiliaryObjectPatterns . concat ( subValue . auxiliaryPatterns ) ; } } return { terms : [ subject ] , auxiliaryPatterns : auxiliaryObjectPatterns } ; } }