R
Railway•14mo ago
faithfulcodes

Creating service with REF environment variables dont work

mutation ServiceCreate { serviceCreate(input: { name: "Service with Variables" environmentId: "id" projectId: "id" variables: { REDIS_URL: "${{Redis.REDIS_URL}}" REDISHOST: "${{Redis.REDISHOST}}" } }) { createdAt deletedAt icon id name projectId updatedAt } } it shows up as empty string but when you try to edit it you can see the ref is correct
No description
No description
62 Replies
Percy
Percy•14mo ago
Project ID: da74a7b7-d8ce-41b1-9c8c-9f59ed8d420f
faithfulcodes
faithfulcodesOP•14mo ago
da74a7b7-d8ce-41b1-9c8c-9f59ed8d420f
Brody
Brody•14mo ago
if you clicked those check marks then clicked the eye icon, would they then render properly?
faithfulcodes
faithfulcodesOP•14mo ago
Yes they would
Brody
Brody•14mo ago
interesting, ill see if i can reproduce
faithfulcodes
faithfulcodesOP•14mo ago
Alright thanks Let me know when you have an update
Brody
Brody•14mo ago
i can reproduce this, going to tag in @jr here not that this would cause any issues id just like to note that you should keep your variables separate from the query, like so
mutation ServiceCreate($input: ServiceCreateInput!) {
serviceCreate(input: $input) {
createdAt
deletedAt
icon
id
name
projectId
updatedAt
}
}
mutation ServiceCreate($input: ServiceCreateInput!) {
serviceCreate(input: $input) {
createdAt
deletedAt
icon
id
name
projectId
updatedAt
}
}
{
"input": {
"environmentId": "",
"projectId": "",
"variables": {
"REDIS_URL": "${{Redis.REDIS_URL}}"
}
}
}
{
"input": {
"environmentId": "",
"projectId": "",
"variables": {
"REDIS_URL": "${{Redis.REDIS_URL}}"
}
}
}
faithfulcodes
faithfulcodesOP•14mo ago
Yeah noted
Brody
Brody•14mo ago
jr will drop by when he has the time
faithfulcodes
faithfulcodesOP•14mo ago
Alright. thanks. Currently building a service and this like a major blocker for me ATM
Brody
Brody•14mo ago
as a work around, you can call ServiceCreate without variables, then call variableCollectionUpsert with the variables, this has the desired effect of rendering the variables
mutation variableCollectionUpsert($input: VariableCollectionUpsertInput!) {
variableCollectionUpsert(input: $input)
}
mutation variableCollectionUpsert($input: VariableCollectionUpsertInput!) {
variableCollectionUpsert(input: $input)
}
{
"input": {
"environmentId": "",
"projectId": "",
"replace": true,
"serviceId": "",
"variables": {
"REDIS_URL": "${{Redis.REDIS_URL}}"
}
}
}
{
"input": {
"environmentId": "",
"projectId": "",
"replace": true,
"serviceId": "",
"variables": {
"REDIS_URL": "${{Redis.REDIS_URL}}"
}
}
}
jr
jr•14mo ago
This is indeed a bug. Thanks for the flag. Calling variableCollectionUpsert will work. The reason why is that we convert the service name to an id behind the scenes but that is not happening in the serviceCreate mutation
faithfulcodes
faithfulcodesOP•14mo ago
Alright thanks Do i need to redeploy the service for the update to take effect? I wanted the variable to available at service creation but that doesn't seem to be the case
jr
jr•14mo ago
yes you will need to redeploy
Brody
Brody•14mo ago
1. create service without source and without variables 2. add variables to service 3. add source to service with serviceConnect yes it's 3 api calls, but far better than having to restart the service
faithfulcodes
faithfulcodesOP•14mo ago
Thank you. So i was thinking what if we are able to fetch the variables from the plugin and then poplutate the the createService variables with the actual values instead of REF
Brody
Brody•14mo ago
not ideal, you always want to use reference variables
faithfulcodes
faithfulcodesOP•14mo ago
Solid. Thanks @Brody THis add source to service with ServiceInstanceUpdate does't trigger a deployment the repo has a railway.toml file but that doesn't seem to trigger the deployment what variables do i need to pass tot trigger the deployments if i have to use the ServiceInstanceUpdate
Brody
Brody•14mo ago
my bad
mutation serviceConnect($id: String!, $input: ServiceConnectInput!) {
serviceConnect(id: $id, input: $input) {
id
name
icon
createdAt
projectId
}
}
mutation serviceConnect($id: String!, $input: ServiceConnectInput!) {
serviceConnect(id: $id, input: $input) {
id
name
icon
createdAt
projectId
}
}
{
"id": "",
"input": {
"branch": "",
"repo": ""
}
}
{
"id": "",
"input": {
"branch": "",
"repo": ""
}
}
this will trigger a deploy after calling it use that instead of ServiceInstanceUpdate
faithfulcodes
faithfulcodesOP•14mo ago
I used this and it was throwing and error about serviceInstance not being found
Brody
Brody•14mo ago
i just tested it and it worked perfectly the id is a service id btw
faithfulcodes
faithfulcodesOP•14mo ago
yeah yeah give me a minute the error ServiceInstance not found: {"response":{"errors":[{"message":"ServiceInstance not found","locations":[{"line":2,"column":3}],"path":["serviceConnect"],"extensions":{"code":"INTERNAL_SERVER_ERROR","exception":{"status":404}}}],"data":null,"status":200,"headers":{}},"request":{"query":"mutation ServiceConnect($id: String!, $input: ServiceConnectInput!) {\n serviceConnect(id: $id, input: $input) {\n createdAt\n icon\n id\n name\n projectId\n }\n}","variables":{"id":"233b4357-5130-445c-b1db-f513ebac5981","input":{"branch":"main","repo":"KinfolkVC/cuuro-email-sync-engine"}}}} @Brody
Brody
Brody•14mo ago
no need for the ping #🛂|readme #5
faithfulcodes
faithfulcodesOP•14mo ago
ohhh sorry about that
Brody
Brody•14mo ago
can you show me the query in your code
faithfulcodes
faithfulcodesOP•14mo ago
It actually tiggers but the response i get does not allow me to move tot the next step in my code export const ServiceConnect = graphql( mutation ServiceConnect($id: String!, $input: ServiceConnectInput!) { serviceConnect(id: $id, input: $input) { createdAt icon id name projectId } } ); async connectServiceToSource(serviceId: string, source: string) { const response = await this.graphQLClient.request(ServiceConnect, { id: serviceId, input: { branch: 'main', repo: source, }, }); return response.serviceConnect; }
Brody
Brody•14mo ago
is your client trying to validate to some schema or something?
faithfulcodes
faithfulcodesOP•14mo ago
i dont think so
Brody
Brody•14mo ago
well im not sure exactly, but this would just be a code issue
faithfulcodes
faithfulcodesOP•14mo ago
Every other query works fine except this
Brody
Brody•14mo ago
just a code issue, im sure youll get it sorted soon
faithfulcodes
faithfulcodesOP•14mo ago
aiit I just tried it with postman returns same error
faithfulcodes
faithfulcodesOP•14mo ago
No description
faithfulcodes
faithfulcodesOP•14mo ago
This is the post man query returns the exact same error.
Brody
Brody•14mo ago
thats a different error
faithfulcodes
faithfulcodesOP•14mo ago
Its the same tho
Brody
Brody•14mo ago
its not the same error lol slow down and read please
Brody
Brody•14mo ago
with the correct variables, the mutation works fine
No description
Brody
Brody•14mo ago
ignore the fact that im using the internal endpoint, it makes no difference
you should keep your variables separate from the query
faithfulcodes
faithfulcodesOP•14mo ago
No description
faithfulcodes
faithfulcodesOP•14mo ago
I did exactly this
Brody
Brody•14mo ago
no you didnt
faithfulcodes
faithfulcodesOP•14mo ago
No description
Brody
Brody•14mo ago
please setup postman like how i have it
faithfulcodes
faithfulcodesOP•14mo ago
At the code level i did I am saying the request triggers the deployement but the response is an error can you please try to repoduce with the external api,
Brody
Brody•14mo ago
it makes no difference
Brody
Brody•14mo ago
but sure
No description
Brody
Brody•14mo ago
^
faithfulcodes
faithfulcodesOP•14mo ago
No description
Brody
Brody•14mo ago
what kind of id are you using
faithfulcodes
faithfulcodesOP•14mo ago
the service id
Brody
Brody•14mo ago
is it correct?
faithfulcodes
faithfulcodesOP•14mo ago
yes it is
faithfulcodes
faithfulcodesOP•14mo ago
No description
Brody
Brody•14mo ago
jr is in dnd mode are you on pro?
faithfulcodes
faithfulcodesOP•14mo ago
nope Currently in talks with the team. We are moving away from AWS. We are still building and making sure everything is working perfectly before we decide.
Brody
Brody•14mo ago
the only thing that comes to mind is you being on the trial plan
faithfulcodes
faithfulcodesOP•14mo ago
Hmmm Just upgraded to hobby plan let me test again Same error Its funny that it actually triggers but returns an error response
Brody
Brody•14mo ago
we wait for jr (he is busy cooking up cool new railway features)
faithfulcodes
faithfulcodesOP•14mo ago
Alright cool Hi Brody Any update on this
Brody
Brody•14mo ago
sorry i dont, ill tag jr again next week for you @jr any ideas what could be going on here?
jr
jr•14mo ago
So just to confirm, the problem is that the serviceConnect mutation is returning an error (but it is deploying in the UI)?
Want results from more Discord servers?
Add your server