graphql-hive / graphql-hive/SOFA

Ordering of query definitions changing Model vs. not Model determination?

Open
#1,007 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.1k
Forks
91
Avg merge
5h 10m
Merged PRs (30d)
1

Description

I'm encountering an issue where _the order in which queries are defined_ is determining whether or not a type (`Recording`, below) is correctly interpreted as a `Model` (so, just the `id` field included), vs. incorrectly interpreted (keeping all fields of nested `Recording` objects, not just the `id`).

I'm using Sofa (0.10.2), and constructing queries using `nexus-prisma` v0.35.0 (see below).

Anyone encountering behavior like this?

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

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

//If this resolver definition is ABOVE the 'recordings' resolver, behavior is as expected;
//nested recording objects are limited to the id field.
//if this is BELOW the 'recordings' resolver, the behavior is unexpected;
//full nested Recording object are shown by other resolvers.
//=================
t.nonNull.list.nonNull.field('resolverForDebugging', {
type: Recording.$name,
args: { bob: stringArg() },
resolve(_, args, ctx) { return ctx.prisma.recording.findMany() }
}),
//=================

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.