Matt
09/22/2020, 4:07 PMnullable: true
(except id). What I'm concerned with is what if the user includes an arg of some_required_field: null
. Is there anything to prevent them doing this? Or do I need to write custom code to look through the args for any fields that are set to null that shouldn't be?Pieter
09/23/2020, 1:41 PM@typescript-eslint/no-unused-vars
rule and we are not ignoring the generated types from @nexus/schema
due to needing the file in git for our tsc builds and we had an issue with massive git diffs when some team members linted from outside the root and eslint didn't ignore the changes, so we enforce it to be linted now.
The problem is that after upgrading fron nexus 0.12
to @nexus/schema
we end up with this code at the bottom of the generated types:
declare global {
interface NexusGenPluginTypeConfig<TypeName extends string> {
}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {
}
interface NexusGenPluginSchemaConfig {
}
}
Eslint then throws this error:
3238:38 error 'TypeName' is defined but never used @typescript-eslint/no-unused-vars
3240:39 error 'TypeName' is defined but never used @typescript-eslint/no-unused-vars
3240:64 error 'FieldName' is defined but never used @typescript-eslint/no-unused-vars
I can't add a // eslint-disable
comment as the file gets regenerated the whole time. How do I fix this?
CC @RyanPieter
09/23/2020, 5:08 PMschema.addToContext()
but that seem to run each time a new resolver is triggered (so multiple times per request depending on the size of the gql query and the list count)
I've thus removed the async data fetching from the addToContext
method and added server.express.use
middleware right above it in the same file.
This seems to work great in dev mode with ts-node-dev --transpile-only api/graphql.ts
which is my entrypoint that imports all the relevant files in order (context is at the top) and calls app.assemble()
as I need this for vercel deployments.
The problem is that in production (after running nexus build --entrypoint api/graphql.ts
the express middleware do not seem to be running at all, despite running in dev.Swapnull
09/23/2020, 5:54 PMschema.extendType({
type: 'Query',
definition: (t) => {
t.int('getDistance', {
args: {
location1: schema.stringArg(),
location2: schema.stringArg(),
},
resolve: async (_root, args, ctx) => {
/* does maths and returns int */
},
})
},
})
I then have 2 objects like
schema.objectType({
name: 'events',
definition(t) {
t.model.uuid()
t.model.location()
}
})
schema.objectType({
name: 'suppliers',
definition(t) {
t.model.uuid()
t.model.location()
}
})
I basically want to say “For 1 supplier, find all events within a distance”.
In JS you would do it like
const getEvents = (supplier, events, distance = 1000) =>
events.filter(e => getDistance(e.location, supplier.location) < distance);
I want to do this while also having other where clauses
query test($supplierId: String, $supplierLocation: String, $distance, $order: [eventsOrderByInput!], $startDate: DateTime, $endDate: DateTime) {
events(first: 5, orderBy: $order, where: {
date: {gte: $startDate, lte: $endDate}
/* something here that says only include it when getDistance($supplierLocation, event.location) < distance */
}) {
uuid
}
}
Is it possible to use this type of thing? If not, how would people suggest achieving it? Maybe filter by distance on an initial query and then use that query as the base for any other queries or something? Is that even possible?Michael Gardner
09/24/2020, 5:36 PMschema.prisma
to tell the database a precision of float to prevent weird round-off errors? I’m thinking about values of latitude and longitude in a geolocation value.
model Point {
id String @id @default(cuid())
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
Polygon Polygon? @relation(fields: [polygonId], references: [id])
polygonId String?
latitude Float
longitude Float
altitude Float?
}
would be my example for that. If not, I guess the one could adjust the createOnePoint
and createManyPoints
to shave off a few decimals, but it still doesn’t prevent possible data corruption from the storage in the database possibly.
Currently im debating just making them strings and doing a migration later if this becomes a thing.Adam
09/25/2020, 9:38 PMDave
09/26/2020, 1:33 PMserver.express.get('/endpoint', async (req, res, ctx) => {}
I can't however figure out how to access the prisma client from within the call, could anyone point me in the right direction please?windkomo
09/28/2020, 9:38 PMPierre Ortega
09/28/2020, 9:58 PMMatheus Assis
09/29/2020, 7:35 PMquery GetContacts($userId: Int!) {
userContactLists(where: { userId: { equals: $userId } }) {
id
name
}
}
(This is just an example of a query, but there's also mutations that I want to apply that too)
And it only works when there's a token and everything. But the userId property could be any userId, not the logged in user.
What are the recommendations in those situations? I only want to allow if the provided userId is from the current logged in user.Ahmed
09/30/2020, 3:04 PMDaniel Mahon
09/30/2020, 3:21 PMJames Homer
09/30/2020, 3:53 PMDaniel Mahon
09/30/2020, 4:04 PMJames Homer
09/30/2020, 4:06 PMsven
09/30/2020, 4:12 PMAhmed
09/30/2020, 4:13 PMAhmed
09/30/2020, 4:15 PMAdam
09/30/2020, 4:24 PM@nexus/schema
and nexus-plugin-prisma
, does anyone have a link to this announcement?Ahmed
09/30/2020, 4:29 PMAdam
09/30/2020, 4:29 PMPetr Homoky
09/30/2020, 4:30 PMPetr Homoky
09/30/2020, 4:31 PMAdam
09/30/2020, 4:33 PM<http://nexusjs.org|nexusjs.org>
Adam
09/30/2020, 4:33 PM<http://nexus.js.org|nexus.js.org>
accidentally instead of <http://nexusjs.org|nexusjs.org>
Adam
09/30/2020, 4:45 PMnexus-plugin-prisma
today from .19
to .20
and it errors on trying to find prisma.yml
jasonkuhrt
Sytten
09/30/2020, 5:23 PMSytten
09/30/2020, 5:24 PMSytten
09/30/2020, 5:26 PM