I am using Apollo client for GraphQL client integrations. I have added the following run script, which is suggested in the official documentation.
cd "${SRCROOT}/${TARGET_NAME}/GraphQL/Open"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find
. -name '*.graphql') --schema schema.json
--output APIClient.swift
But the problem that is coming up is all the scalar are right now coming up as String.
For Example:- while logging in if I create a mutation of email and password, my schema returns response as JSON while APIClient created shows response as String(instead of JSON).
Due to this there is an error received which says
Apollo.GraphQLResultError(path: ["login", "response"], underlying: Apollo.JSONDecodingError.couldNotConvert
this is because String is received instead of JSON and string can not be converted into required JSON.
Is anyone facing the same issue?
So I had figured it out. The solution is to add
--passthrough-custom-scalars
in the run script. This will pass custom scalars like JSON. So the complete runscript becomes
cd "${SRCROOT}/${TARGET_NAME}/GraphQL/Open"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find
. -name '*.graphql') --schema schema.json --passthrough-custom-scalars
--output APIOpen.swift
Now when the code is recomplied along with this run script the JSON scalar becomes valid.
This took me a lot of time to figure out. Hope it helps someone and save their time. Thanks
Related
This is inside my trigger email
SQLScripts=["Query1","Query2","Query3","Query4","Query5","Query6"]
What gets read in string parameter for Jenkins build is following
This line of code executes
echo %SQLScripts%
Prints
echo ["Query1","Query2","Query3",
Initially I thought this could be some problem with how I wrote variable name, I tried $SQLScripts and "$SQLScripts". But problem is with reading the variable from email.
As I have manually added value inside jenkins build configuration and echo printed the entire value.
Please any help is appreciated.
How can I call textinput.py from another python file? I would like to call it and send a text query as an argument rather than getting the input from the user.
Thank you
I 've used this method and it is working. I hope it is the correct way.
import os os.system('/home/pi/env/bin/python3 textinput.py --query \'XXXX\' --device-id XXX --device-model-id XXXXXX')
I see in the Docker Remote API Docs that filter can be used to filter on status but I'm unsure how to form the request:
https://docs.docker.com/reference/api/docker_remote_api_v1.16/#list-containers
GET /containers/json?filters=status[exited] ?????
How should this be formatted to display ONLY exited containers?
jwodder is correct on the filter but I wanted to go through this step by step as I wasn't familiar with the Go data types.
The Docker API documentation refers to using a map[string][]string for a filter, which is a Go map (hash table)
map[string] defines a map with keys of type string
[]string is the type definition for the values in the map. A slice
[] is an array without fixed length. Then the slice is made up of
string values.
So the API requires a hash map of arrays containing strings. This Go Playground demonstrates marshalling the Go filter data:
mapS := map[string][]string{ "status":[]string{"exited"} }
Into JSON:
{ "status": [ "exited" ] }
So adding that JSON to the Docker API request you get:
GET /containers/json?all=1&filters={%22status%22:[%22exited%22]}
all=1 is included to report exited containers (like -a on the command line).
It might be easier for non Go people if they just documented the JSON structure for the API : /
The most elegant way to use docker with curl and don't bother with encoding I found in this answer. Basically, it's tell curl to use data as query parameter and encode it. To get exited container the query may look like:
curl -G -XGET "http://localhost:5555/containers/json" \
-d 'all=1' \
--data-urlencode 'filters={"status":["exited"]}' | python -m json.tool
By my reading of the docs, it should be:
GET /containers/json?filters={"status":["exited"]}
Some of that might need to be URL-encoded, though.
I'm building an iOS application that communicates with a remote server. In this case, I'm executing commands using SSH, however, the response coming back from the server is coming in the form of what appears to be hexadecimal. My delegate function for handling responses from a remote server takes the response argument as an NSString, however, this is the content of the string returned (command executed was "ls /" )
ls /\r\n\x1b[0m\x1b[01;34mbin\x1b[0m \x1b[01;34mdev\x1b[0m \x1b[01;36minitrd.img\x1b[0m \x1b[01;34mlib64\x1b[0m \x1b[01;34mmnt\x1b[0m \x1b[01;34mroot\x1b[0m \x1b[01;34msrv\x1b[0m \x1b[01;34musr\x1b[0m\r\n\x1b[01;34mboot\x1b[0m \x1b[01;34metc\x1b[0m \x1b[01;36minitrd.img.old\x1b[0m \x1b[01;34mlost+found\x1b[0m \x1b[01;34mopt\x1b[0m \x1b[01;34mrun\x1b[0m \x1b[01;34msys\x1b[0m \x1b[01;34mvar\x1b[0m\r\n\x1b[01;34mcdrom\x1b[0m \x1b[01;34mhome\x1b[0m \x1b[01;34mlib\x1b[0m \x1b[01;34mmedia\x1b[0m \x1b[01;34mproc\x1b[0m \x1b[01;34msbin\x1b[0m \x1b[30;42mtmp\x1b[0m \x1b[01;36mvmlinuz\x1b[0m'
If this is in fact hexadecimal, how to I convert this back to a readable string for display purposes? If it's not hexadecimal, does anyone know what it is?
EDIT:
Since this is ANSI Color Control Codes, what's the best method to remove them?
prepend "\" to the beginning of the command
$ \ls
or provide handling for the escape sequences (strip, display)
Problem
I'm trying to filter a json JQ result to only show a substring of the original string. For example if a JQ filter grabed the value
4ffceab674ea8bb5ec421c612536696839bbaccecf64e851dfc270d795ee55d1
I want it to only return the first 10 characters 4ffceab674.
What I've tried
On the Official JQ website you can find an example that should give me what I need:
Command: jq '.[2:4]'
Input: "abcdefghi"
Output: "cd"
I've tried to test this out with a simple example in the unix terminal:
# this works fine, => "abcdefghi"
echo '"abcdefghi"' | jq '.'
# this doesn't work => jq: error: Cannot index string with object
echo '"abcdefghi"' | jq '.[2:4]'
So, it turns out most of these filters are not yet in the released version. For reference see issue #289
What you could do is download the latest development version and compile from source. See download page > From source on Linux
After that, if indexing still doesn't work for strings, you should, at least, be able to do explode, index, implode combination, which seems to have been your plan.
Looking at the jq-1.3 manual I suspect there isn't a solution using that version since it offers no primitives for extacting parts of a string.