New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
directives are lost when using custom scalars #1587
Comments
Could you share a reproduction of your issue as a GitHub repo or CodeSandbox? |
For sure of course. https://codesandbox.io/s/visitscalar-example-8zxsr. I tried to break down all of the different pieces pretty small. of course the example domain is just a bogus scenario. Sample Query
|
Can't seem to see logs from sandbox, when does it fire for you, or is it not firing? |
@yaacovCR I was just seeing them in the terminal window, but I simplified it to just be a console.log statement. As for should fire on schema creation, agree. I saw that code as too, but I'm not seeing that happen in my setup, like I see the other directives. I'm guessing, I just don't know what I'm doing, but I'm at a loss to what I'm doing wrong. |
graphql-tools since at least v4 overwrites the astNode from the original schema with the empty astNode from the custom scalar, which is likely undefined. We could at least check for undefined before overwriting.... https://github.com/ardatan/graphql-tools/blob/master/packages/schema/src/addResolversToSchema.ts#L145 Likely affects enums with internal values as well, additional types, etc, etc. |
Workaround for now is to only select properties you want from custom scalar, ie parseValue, parseLiteral, serialize... |
Looks like i got it working... See comment on PR for instructions on how to test: #1623 (comment) See forked sandbox: https://codesandbox.io/s/visitscalar-example-6oxvj?file=/graphql/index.js |
@csell5 if you are able to confirm fix, would be great, another set of eyes would be much appreciated |
Verified... Thank you so much for getting after this so fast. What's the thinking behind not having a |
@yaacovCR Well, maybe there is still a bug here. It appears to only fire when makeExecutableSchema is called. See here: https://codesandbox.io/s/visitscalar-example-8zxsr?file=/graphql/index.js If you just pass in typedefs, resolvers, and the schemaDirectives to apollo server it will not fire. But if you either call makeExecutableSchema or take the result of makeExecutableSchema and pass it in, then it fires. |
Nothing we can do about that, we are now separate from Apollo, which is internally using v4, to use latest fixes, you have to explicitly construct schema with makeExecutableSchema |
@csell5 could you explain what you mean a little bit more in terms of your question about resolver function on some directives? Maybe a code sample comparing what you expected and what you are seeing |
I apologize if it's kind of obvious my brain seems to be working a little slowly today |
Right of course.. I wasn't even thinking about that. |
@csell5 and if you have a second to explain your question here? |
Sure.. Let's just look at Again, I'm just trying to get a grasp on the thinking here. |
I'm clearly missing something fundamental and I'm hoping someone here could point me in the right direction. I've been working through trying to understand all the ins and outs of Directives and vistScalar and visitInterface seem to have lead me to nothing but dead ends.
If one creates a directive aligned to SCALAR. When does visitScalar actually fire?
Thank you in advance!
The text was updated successfully, but these errors were encountered: