graphql-nexus/nexus-prisma

Ordering of query definitions impacting results?

kleydon opened this issue · 1 comments

Different orderings of the (functional) queries below - constructed by nexus-prisma (0.35.0) - are resulting in differing behaviors in another library (Sofa 0.10.2).

Is it to be expected that the order in which queries are defined can change resulting behavior?

Should one particular ordering be enforced (say, alphabetical), as is done when prisma is writing schema.graphql?

Food for thought...


// If Query #2 is placed below Query #3, instead of above, 
// the behavior changes in Sofa (a widely-used GQL->REST API translator).


export const recordingQueries = extendType({
  type: 'Query',
  definition(t) {

    //1.
    t.field('recording', {
      type: Recording.$name,
      args: { id: idArg() },
      resolve(_, args, ctx) {
        return ctx.prisma.recording.findUnique({ where: { id: args.id ?? undefined }})
      }
    }),

    //2.
    t.nonNull.list.nonNull.field('resolverForDebugging', {
      type: Recording.$name,
      args: { bob: stringArg() },
      resolve(_, args, ctx) { return ctx.prisma.recording.findMany() }
    }),

   //3.
    t.nonNull.list.nonNull.field('recordings', {
      type: Recording.$name,
      resolve(_, __, ctx) { return ctx.prisma.recording.findMany() }
    })
  }
})

This looks like a Prisma issue? I don't see Nexus Prisma being used in your repro.