Sam Michael
03/23/2022, 8:30 AMbod
03/23/2022, 8:35 AMSam Michael
03/23/2022, 8:37 AMbod
03/23/2022, 8:41 AM__typename
), they may differ.Sam Michael
03/23/2022, 8:49 AMbod
03/23/2022, 8:58 AMwasyl
03/23/2022, 2:40 PMi may try preemptively adding __typename lolIn 3.x not every type has
__typename
though. What I tend to do is open the relevant SomeOperationQuery
generated file, copy the entire string from QUERY_DOCUMENT
(including trimMargin()
but not including QueryDocumentMinifier.minify
) and run
pbpaste | kotlinc-jvm | tail -n +3 | sed '$d' | sed 's/^.*kotlin.String = //g' | pbcopy
in the terminal. That will run the code as a Kotlin script, do some string magic to only get the output and copy it back to the clibpoard. Very useful, although that’s for mac obviously.
You can also get the QUERY_DOCUMENT
string and run it in a Kotlin scratch file in Android Studio and copy the outputephemient
03/23/2022, 4:08 PMSam Michael
03/24/2022, 1:37 PM__typename
field did the trick after all in this instance 😂 , but looking into all the suggestions above for more longterm solutions.
pbpaste | kotlinc-jvm | tail -n +3 | sed '$d' | sed 's/^.*kotlin.String = //g' | pbcopy
1. For this command, so the idea is to take the output it copies to the clipboard and register that as your operation? Sorry had a little trouble following
2. I tried turning on generateOperationOutput but haven't been able to locate the json file or where it is outputting to. 😣 Apologies for being a little densebod
03/24/2022, 1:54 PMbuild/generated/operationOutput/apollo/service/operationOutput.json
wasyl
03/24/2022, 1:56 PMFor this command, so the idea is to take the output it copies to the clipboard and register that as your operation?I don’t register the operations, I was just sharing my way of getting the exact query (functionally) that Apollo will make
Sam Michael
03/24/2022, 1:57 PMpbpaste | kotlinc-jvm | tail -n +3 | sed '$d' | sed 's/^.*kotlin.String = //g' | pbcopy "query SomeQuery ..."
like this?wasyl
03/24/2022, 2:13 PMpbpaste
will paste the string from the clipboard, and pbcopy
will copy it back. So this works when you copy the query string from the SomeQuery
file to the clipboard, run the command I pasted (without changes, and provided you have kotlinc-jvm in your path), and it’ll put the cleaned up query in your clipboardSam Michael
03/24/2022, 2:14 PM