@@ -123,78 +123,11 @@ async function repo(_, { id }, { userId }) {
123123 include : {
124124 owner : true ,
125125 collaborators : true ,
126- pods : {
127- include : {
128- children : true ,
129- parent : true ,
130- } ,
131- orderBy : {
132- index : "asc" ,
133- } ,
134- } ,
135- edges : true ,
136126 } ,
137127 } ) ;
138128 if ( ! repo ) throw Error ( "Repo not found" ) ;
139129 await updateUserRepoData ( { userId, repoId : id } ) ;
140- return {
141- ...repo ,
142- edges : repo . edges . map ( ( edge ) => ( {
143- source : edge . sourceId ,
144- target : edge . targetId ,
145- } ) ) ,
146- } ;
147- }
148-
149- async function addEdge ( _ , { source, target } , { userId } ) {
150- if ( ! userId ) throw new Error ( "Not authenticated." ) ;
151- const sourcePod = await prisma . pod . findFirst ( { where : { id : source } } ) ;
152- const targetPod = await prisma . pod . findFirst ( { where : { id : target } } ) ;
153- if ( ! sourcePod || ! targetPod ) throw new Error ( "Pods not found." ) ;
154- if ( sourcePod . repoId !== targetPod . repoId )
155- throw new Error ( "Pods are not in the same repo." ) ;
156- await ensureRepoEditAccess ( { repoId : sourcePod . repoId , userId } ) ;
157- await prisma . edge . create ( {
158- data : {
159- source : {
160- connect : {
161- id : source ,
162- } ,
163- } ,
164- target : {
165- connect : {
166- id : target ,
167- } ,
168- } ,
169- repo : {
170- connect : {
171- id : sourcePod . repoId ,
172- } ,
173- } ,
174- } ,
175- } ) ;
176- return true ;
177- }
178-
179- async function deleteEdge ( _ , { source, target } , { userId } ) {
180- if ( ! userId ) throw new Error ( "Not authenticated." ) ;
181- const sourcePod = await prisma . pod . findFirst ( { where : { id : source } } ) ;
182- const targetPod = await prisma . pod . findFirst ( { where : { id : target } } ) ;
183- if ( ! sourcePod || ! targetPod ) throw new Error ( "Pods not found." ) ;
184- if ( sourcePod . repoId !== targetPod . repoId )
185- throw new Error ( "Pods are not in the same repo." ) ;
186- await ensureRepoEditAccess ( { repoId : sourcePod . repoId , userId } ) ;
187- await prisma . edge . deleteMany ( {
188- where : {
189- source : {
190- id : source ,
191- } ,
192- target : {
193- id : target ,
194- } ,
195- } ,
196- } ) ;
197- return true ;
130+ return repo ;
198131}
199132
200133async function createRepo ( _ , { } , { userId } ) {
@@ -215,21 +148,6 @@ async function createRepo(_, {}, { userId }) {
215148 return repo ;
216149}
217150
218- async function getVisibility ( _ , { repoId } , { userId } ) {
219- if ( ! userId ) throw Error ( "Unauthenticated" ) ;
220- const repo = await prisma . repo . findFirst ( {
221- where : {
222- id : repoId ,
223- owner : { id : userId || "undefined" } ,
224- } ,
225- include : {
226- collaborators : true ,
227- } ,
228- } ) ;
229- if ( ! repo ) throw Error ( "Repo not found" ) ;
230- return { collaborators : repo . collaborators , isPublic : repo . public } ;
231- }
232-
233151async function updateVisibility ( _ , { repoId, isPublic } , { userId } ) {
234152 if ( ! userId ) throw Error ( "Unauthenticated" ) ;
235153 const repo = await prisma . repo . findFirst ( {
@@ -414,43 +332,6 @@ async function unstar(_, { repoId }, { userId }) {
414332 return true ;
415333}
416334
417- async function updatePod ( _ , { id, repoId, input } , { userId } ) {
418- if ( ! userId ) throw new Error ( "Not authenticated." ) ;
419- await ensureRepoEditAccess ( { repoId, userId } ) ;
420- // if repoId has id, just update
421- let pod_found = await prisma . pod . findFirst ( {
422- where : {
423- id,
424- repo : {
425- id : repoId ,
426- } ,
427- } ,
428- } ) ;
429- // or, return false and leave it dirty
430- if ( ! pod_found ) return false ;
431- const pod = await prisma . pod . update ( {
432- where : {
433- id,
434- } ,
435- data : {
436- ...input ,
437- parent : input . parent
438- ? input . parent === "ROOT"
439- ? { disconnect : true }
440- : {
441- connect : {
442- id : input . parent ,
443- } ,
444- }
445- : undefined ,
446- children : {
447- connect : input . children ?. map ( ( id ) => ( { id } ) ) ,
448- } ,
449- } ,
450- } ) ;
451- return true ;
452- }
453-
454335async function copyRepo ( _ , { repoId } , { userId } ) {
455336 // Find the repo
456337 const repo = await prisma . repo . findFirst ( {
@@ -525,9 +406,6 @@ export const RepoResolver = {
525406 updateRepo,
526407 deleteRepo,
527408 copyRepo,
528- updatePod,
529- addEdge,
530- deleteEdge,
531409 addCollaborator,
532410 updateVisibility,
533411 deleteCollaborator,
0 commit comments