Type '{ id: string; s3Bucket: string; }' is not assignable to type 'ImageStoreCreateOrConnectWithoutEventInput'. Object literal may only specify known properties, and 'id' does not exist in type 'ImageStoreCreateOrConnectWithoutEventInput'.
drilling into it takes me to index.d.ts which I don’t expect to have to modify…
I had added id to the CreateImageStoreInput in imageStore.ts but that wasn’t enough…
@ajoslin103 I have seen you use the above code pattern often and I am curious about what you’d like logged here.
I ask because am adding better logging support at the GraphQL execution level to do debug/info logs when an operation (query/mutation) occurs and also any errors raised.
I’m wondering with these additions if that pattern would be needed – or if it will suffice to log that info. Of course, this would not be logged if you used the service from a serverless function ie - not via GraphQL.
Do you debug log the entire object here? then(thenDebug('user')) ?
Also, is there a reason you do:
return Promise.resolve(null)
and not make user() async and then use await on return db.user()? Or is that done explicitly so you can wrap that then debug around (and if so maybe GraphQL logging can clean that up).
Hope to have that in for the next release and can revisit.
@dthyresson thank you for inquiring. I use thenDebug to log the entire object at any point in any given .then chain. I like it because I can move it up and down the chain as needed.
It has a few shortcomings which could likely be solved if it were written into a logger.
it has no awareness of logLevel - I have to use thenInfo & thenWarn to use different levels
It has no redaction capabilities - something which I like about your logger
It fails when I try to log circular objects, unless I import safe-stringify code
While I truly enjoy both async/await and promises I can’t always figure out how to translate between the two. If I really understand all the things a given bit of code is trying to do I may convert a Promise-based function to an async function if it’s going to make it easier to reason about, but I usually don’t do that where it’s going to create a question for me later. If I enter the room and all the functions are using Promises I am unlikely to switch one signature to async/await unless I’m feeling confident I could change them all.
In this case I return Promise.resolve(null) because the routine is already returning Promises. Most times I am trying to make sense of a suite of functions, and making minimal changes to existing code helps more than rewriting it and [probably] introducing more uncertainty into a situation I don’t fully understand to begin with.
I wish I was a better at reading and understanding code, and that I had better habits of isolating and understanding code before I used it [usually in haste.]
Thanks much for that info @ajoslin103 – I think we can make this a bit easier, cleaner in some updating GraphQL updates. Stay tuned!
In short - there could be a few options to configure logging in GraphQL - to include operationName, requestId, query, trace timings, and even some output that could replace what you are doing in services.