-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Core
-
Labels:None
-
ToDo:
-
Asterisk Version:16
-
Distro Version:15
-
Distro:FreePBX Distro
Ive found an peculiarity in the Graphql APIs for Inbound Route.
Reference documentation:
https://wiki.freepbx.org/display/FPG/Core+Module+GraphQL+APIs#CoreModuleGraphQLAPIs-AddInboundRoute
Each and every one of the Boolean fields that are flagged as Optional are indeed Mandatory.
Example:
{{mutation {
addInboundRoute(input:
) {
inboundRoute
status
message
}
}}}
{{mutation {addInboundRoute( input:
{ extension:"3068675309" cidnum:"" description:"Description Goes Here" privacyman:false ringing:true grppre:"SHOL" pricid:false reversal:true fanswer:true destination:"app-blackhole,no-service,1"}
) { inboundRoute
{ id }
status
message }}}}
will return a success or error with descriptive messaging.
however, removing one of the "Optional" fields, such as answer will return a garbage "Internal server error" message.
I believe this is related to Core.class.php and the AddDIDDefaults function, however I have not been able to resolve it.
The logic used in the GraphQL API is also hot garbage... its is Very inefficient.
it:
-creates an empty array for "Defaults"
-calls the addDIDDefaults with this empty array (which should return the default values)
- iterates over all Default values, and sets the INPUT array to the defaults, if not set
(so now, input is the input, plus any un-set defaults) - Merges the Input array with the defaults Again (this step is useless)
then calls core.class.php's GetDID
which once again runs the addDIDDefaults function.
Every "String" field that is optional is indeed optional.
it breaks if any of the Boolean fields are omitted.
Changing the add defaults function to set the field to false, '', '0', 'CHECKED'. all have no success. (the actual SQL reports these fields are varchar(20)'s for some reason and not booleans...
Partial workaround: set the boolean fields in your graphql API call (example:
{{mutation
{ addInboundRoute(input:
)
{ inboundRoute { id }
status
message
}
} }}