-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Null means the opposite of Null #4
Comments
I had the same feeling when I was looking at the spec and trying to implement it. I did notice it at first but went ahead on implementing it. I quickly got stuck because of the implementation of fields marked I tried working around it when @benwilson512 brought up the point that using The suggesting of sending empty strings would still not make much sense, and if we're changing this I'd much rather suggest on putting the file's key as string as a value of the variable. I know that requires significant changes on both the client and server. PS. Using the file keys as strings as value will also make handling batched operations much easier, since you don't have to know what the number of the operation is, just the file key, which I think is a nice bonus. |
As I was looking into your current implementations to see if there was a possibility of doing file keys as the value, it seems like the JavaScript server implementation is a little more limited, not allowing to access the context of the request (server implementation, JS API). The |
Absinthe is sufficiently flexible that you could abuse internals and add a pass that would turn the nulls into files prior to the non null validation or something of that sort, it just seems like an undesirable thing to do.
Well, empty strings are a more sensible placeholder than |
Agreed and agreed, that would be the minimum change to make it work without workarounds. I would however prefer a change in which they are sent in both the map and the variables, so whichever the server can read it will use. What do you think about that? edit: it does seem a bit silly to send it twice, but I feel it makes more sense than |
Glad to see more implementations popping up!
React Apollo uses You could make a client implementation that uses In false starts I was fully deleting the properties so they don't appear as a key or a value in the operation object being transported, since we have enough information in the file object paths to rebuild them later anyway and less bytes down the wire is nice. I ran into problems with arrays though, because if you have files in a number of the positions extractions change the indexes and it's not certain the array items will be in the same order at the other end. That is why I found it conceptually more robust to work with It makes the request fields more intuitive to inspect too, since whole variables don't appear to be "missing". Although the spec should be about technical elegance and performance than readability, in the same way you are not meant to be able to understand a gzip payload in transport. I am up to something like my fourth client implementation now, and have found it particularly simple to be able to just I have tried and failed to understand the implementation difficulties being discussed here. I don't know Absinthe, but conceptually everything happening with client and server transport implementations is outside the realm of GraphQL. GraphQL systems should never see the |
Hey @jaydenseric, thanks for the reply. I'm not entirely sure that the mechanics of how multipart works on certain platforms are relevant here, nor are conventions about whether For reference, the spec says about the following example: {
field(arg: null)
field
}
So if we have a file upload mutation where the
It puts the server in a position of re-writing a presently invalid document into a valid one. This should be avoided. You can take the position that this is purely a transport concern, but if we go that route then we're no longer transporting GraphQL, we're transporting a dialect thereof.
The user of the GraphQL system may well never see
This feels a bit nit picky given that the number of bytes consumed by Given that it seems like we can be fully spec compliant by the use of an empty string and a custom scalar, I'm unclear on what advantages using |
Transport is not part of GraphQL, what we are doing is not even a dialect of it. An Apollo operation object is something made up for Apollo server and client to use to talk between each other. A lot of GraphQL servers happen to have adopted a similar shape for POST requests, but it is not part of the GraphQL specs. With persisted queries you don't even send a query. Batching is a made-up thing in Apollo, where an array can be sent. Until now, there has been no convention or spec for Multipart GraphQL server POST requests at all.
No it doesn't, if you don't count our upload implementations as part of the "GraphQL system". Our upload middleware converts the multipart request back into something the GraphQL server can later digest, like this. I have had in-person discussions with the Apollo team about building these smarts directly into the official GraphQL server. There has also been a desire to settle on a spec so that Apollo Engine can be taught to work with multipart requests.
An Apollo operations object, where the
Please link to which part of which spec you are referring to. I'm unclear how an empty string would represent a binary file that has not uploaded yet any better than Feel free keep the discussion going, I'll reopen if something concrete comes up 🙂 |
Hey folks,
I'm very happy to see a standardized spec surrounding file uploads, particularly one that lets you treat them as arguments. We've been doing something like this for a while with Absinthe https://hexdocs.pm/absinthe_plug/Absinthe.Plug.Types.html#content but would be happy to change to a more standardized format.
My trouble with this particular setup though is the use of
null
as a placeholder. This issue is both conceptual and technical. From a conceptual perspective we're usingnull
to mean that something is there, which is the precise opposite of whatnull
communicates. From a technical perspective, I'm not entirely sure how this would work with arguments that are marked non null. It seems counterintuitive to permitnull
to be a valid argument to a non null field.Alternatives: If we aren't trying to use the values to mean much of anything then simply an empty string would suffice, and help avoid the problems I've outlined. In the Absinthe implementation the strings point to the HTTP part that contains the file they want, but the mapping solution you have already handles that sort of issue.
Thoughts?
The text was updated successfully, but these errors were encountered: