Whatever message this page gives is out now! Go check it out!
{
author {
id
name
}
}| Parameter | Description | Required |
| service_url | The URL of the server, which contains the schema. You can create your own server or use any of the existing ones. For more information, see the following: | Yes |
| service_name | Specify the name of the server. | Yes |
| client_name | The name of the GraphQL client that you had configured in the ColdFusion Administrator. For more information on configuring the GraphQL service on the ColdFusion Administrator, see GraphQL options. | Yes |
| raw_http_client | (True/False) Attribute to specify whether you must use HTTP Client or Apollo Client internally. | No |
| root_package_name | Specifies the root of your server. For example, if you have two servers, create both the folders in cfusion/gql/main/src, and then you will refer the folders in your pom.xml. The root folder must be unique for each GraphQL service. | No |
| headers | A struct containing:
| Yes |
| batching_configuration | Batching is required by the GraphQL Client to reduce the number of network round trips by enabling multiple operations in a single HTTP call. The param is struct of the following:
If you want batching, then enabled is required. The rest are optional. | No |
| subscription_configuration | A struct of the following:
If you want subscription, then websocket_url is required. | No |
| Exception | Description |
| ValidationException | When config is null/incorrect. |
| ModuleNotAvailableException | When graphqlclient module is not installed. |
// Create GQL object
gqlClient = getGraphQLClient({
service_url : "ENDPOINTURL",
"raw_http_client" : true
});
// This variable will hold your GQL query
Gql = ‘
query
{
Table
{
Column1
Column2
Column3
Column4
}
}
‘
// Assign the response from your query to a variable so you can dump it to screen
response = gqlClient.fetchResponse(gql1, {});gqlClient = getGraphQLClient ({
service_name: "server-name",
type = "graphqlclient",
"raw_http_client": true,
service_url : "endpoint-url",
root_folder: "root_folder",
headers : {
values: "auth-value",
keys: "auth-key"
},
batching_configuration: {
enabled: true,
batch_interval_ms: 10,
max_batch_size: 15
},
subscription_configuration : {
websocket_url: "wss://websocket-url",
subscription_heartbeat_timeout : 5,
subscription_heartbeat_timeunit : "nano"
}
})| Method | Parameters | Returns |
| activeCallsCount() | None | Number of calls made to the query |
addOnSubscriptionManagerStateChangeListener (com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener) | Closure function | None |
| disableSubscriptions() | None | None |
| downloadSchema(java.lang.String, java.lang.String) | Schema of the query | None |
| enableSubscriptions() | None | None |
| getApplicationInterceptorFactories() | None | List |
| getApplicationInterceptors() | None | List |
| getName() | None | Name of the query |
| getSchema(java.lang.String) | None | Returns the GraphQL schema |
| getServerUrl() | None | The URL of the GraphQL server |
| getSubscriptionManager() | None | The subscription manager |
| getSubscriptionManagerState() | None | The state of the subscription manager. |
| mutation(java.lang.String, java.lang.Object) |
| Mutation object |
| query(java.lang.String, java.lang.Object) |
| Query object |
| serverOk() | None | Status of the server, True if server is running, False otherwise |
| shutDown() | None | None |
| startBatchPoller() Non | None | None |
| stopBatchPoller() | None | None |
| subscribe(java.lang.String, java.lang.Object) |
| None |
// get the graphQL service first
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
//"raw_http_client": true,
headers: {
keys: "key",
values: "value" }
});
generateGraphQLModels();
queryObj = gqlClient.query(schema,values)| Method | Parameters | Returns |
| canBeBatched(boolean) | boolean | Returns the query object. |
| cancel() | None | None |
| clone() | None | Returns the cloned object of the operation. |
| enqueue(closure) | enqueue(), execute() would be available on queryObject methods. They would be called on queryObject.execute() or mutationObject.enqueue(onSuccess, onFailure). There would be two closures, one for success, other for failure in enqueue() | None |
| execute() | None | Returns the results from the query object. |
| fields() | None | Returns the fields of the query response. |
| isCanceled() | None | Returns if an operation is canceled (True) or not (False). |
| marshalVariablesJson() | None | Returns JSON data. |
| opName() | None | Returns the name of the query, mutation, or subscription operation. |
| operation() | None | Returns the type of operation. |
| rawOperation() | None | Returns a string. |
| toBuilder() | None | Returns ApolloCall.Builder<T> object. |
| variables() | None | Returns a struct of the variables used in the operation. |
| Method | Parameters | Returns |
| canBeBatched(boolean) Note: Mutations are not supported in batching. | boolean | Returns the query object. |
| cancel() | None | None |
| clone() | None | Returns the cloned object of the operation. |
| enqueue(closure) | Callback to handle any logic of a query operation. For example, OnResponse, OnFailure, OnHTTPError, and so on. | None |
| execute() | None | Returns the results from the query object. |
| fields() | None | Returns the fields of the query response. |
| isCanceled() | None | Returns if an operation is canceled (True) or not (False). |
| marshalVariablesJson() | None | Returns JSON data. |
| opName() | None | Returns the name of the query, mutation, or subscription operation. |
| operation() | None | Returns the type of operation. |
| rawOperation() | None | Returns a string. |
| toBuilder() | None | Returns ApolloCall.Builder<T> object. |
| variables() | None | Returns a struct of the variables used in the operation. |
| Method | Parameters | Returns |
| cancel() | None | None |
| clone() | None | Returns the cloned object of the operation. |
| execute(closure,closure,closure) | Callback to handle any logic of a query operation. For example, OnResponse, OnFailure, OnHTTPError, and so on. | None |
| execute(Closure onConnected, Closure onResponse, subscriptionObject.closure onFailure,Closure onCompleted, Closure onTerminated) | Callback to handle any logic of a query operation. For example, OnResponse, OnFailure, OnHTTPError, and so on. | |
| isCanceled() | None | Returns if an operation is canceled (True) or not (False). |
<cfscript>
adminObj = CreateObject("component","CFIDE.adminapi.administrator");
adminObj.login("admin","admin")
gqlCFC = CreateObject("component","CFIDE.adminapi.graphql")
http_header = {
"x-hasura-admin-secret" = "secret"
}
gqlCFC.setServiceConfiguration(service_name="hasura",root_package_name="root_hasura",service_url="https://hardy-mink-39.hasura.app/v1/graphql",headers=http_header, schema_path="");
sc = {
websocket_url: "wss://hardy-mink-39.hasura.app/v1/graphql",
subscription_heartbeat_timeout : "1",
subscription_heartbeat_timeunit : "days"
}
bc = {
enabled: false
}
gqlCFC.setClientConfiguration(client_name="hasura_client_http",service_cname="hasura",raw_http_client=true,batching_configuration=bc, subscription_configuration=sc);
gqlCFC.updateServiceConfiguration(service_name="hasura",raw_http_client=true, root_package_name="updated_root");
gqlCFC.updateClientConfiguration(client_name="hasura_client_http",raw_http_client=false);
gqlFC.deleteServiceConfiguration("hasura"); Deleting service will delte clients as well
gqlFC.deleteClientConfiguration("hasura_client_http");
</cfscript>type Person {
name: String!
age: Int!
}type Post {
title: String!
author: Person!
}query myCartQuery{
cart(cart_id: String!): Cart
}query myCartQuery{
cart(cart_id: "1WxKm8WUm3uFKXLlHXezew5WREfVRPAn") {
items {
id
quantity
}
billing_address {
firstname
lastname
postcode
}
shipping_addresses {
firstname
lastname
postcode
}
}
}{
"data": {
"cart": {
"items": [
{
"id": "7",
"quantity": 10
}
],
"billing_address": {
"firstname": "James",
"lastname": "Spencer",
"postcode": "12345"
},
"shipping_addresses": [
{
"firstname": "James",
"lastname": "Spencer",
"postcode": "12345"
}
]
}
}
}onSuccess = function(response) {
writeOutput("Received Response from GraphQL Server");
writedump(response.toString());
}
onError = function() {
writeOutput("Error While Receiving Response from GraphQL Server");
}
queryObj = gqlClient.query("Warriors", {});
// async call
queryObj.enqueue(onSuccess, onError);
// sync call
writedump(queryObj.execute())query ($limit: Int) {
author(limit: $limit) {
id
name
}
}
The variable can be set in the following way:
{
limit: 5
}mutation {
addCategory(id: 6, name: "Green Fruits", products: [8, 2, 3]) {
name
products {
name
}
}
}type Subscription {
commentAdded(postID: ID!): Comment
}
On the client side,
subscription OnCommentAdded($postID: ID!) {
commentAdded(postID: $postID) {
id
content
}
}<cfscript>
//Subscription Client Handle Creation
subscrClient = getGraphQLClient({
url = <graphql_server_url>,
webSocketServerUrl = <websocket_server_url>,
wsprotocol = <websocket_protocol>,
subscriptionTrasportFactory = <subscription_transport_factory>,
headers = <ok_http_client>
...
});
subscriptionHandlerCallback = <Callback to Handle the OnCompleted/OnConnected/OnTerminated/OnResponse/OnFailure Logic for Subscription Operation>
subscriptionCall = subscrClient.subscribe(subscriptionObj);
subscriptionCall.execute(subscriptionHandlerCallback);
</cfscript><myservice>
<compilationUnit>
<name>myservice</name>
<compilerParams>
<rootPackageName>root</rootPackageName>
</compilerParams>
</compilationUnit>
<introspection>
<enabled>true</enabled>
<endpointUrl
>https://apollo-fullstack
tutorial.herokuapp.com/graphql</endpointUrl
>
<headers></headers>
<connectTimeoutSeconds>10</connectTimeoutSeconds>
<readTimeoutSeconds>10</readTimeoutSeconds>
<writeTimeoutSeconds>10</writeTimeoutSeconds>
<useSelfSignedCertificat>false</useSelfSignedCertificat>
<useGzip>false</useGzip>
<prettyPrint>false</prettyPrint>
</introspection>
</myservice><cfscript>
// get the graphQL service first
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
headers : {
keys: "Authorization",
values: "value"
}
});
generateGraphQLModels();
queryObj = gqlClient.query("MissionDetails", {});
response=queryObj.execute()
response.get("Data")
</cfscript><cfscript>
// get the graphQL service first
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
headers : {
keys: "Authorization",
values: "value"
}
});
generateGraphQLModels();
queryObj = gqlClient.query("TripsBooked", {});
//writedump(queryObj);
response=queryObj.execute()
// writeDump(response.get("Data"))
</cfscript>subscription TripsBookedSub {
tripsBooked
}
File.cfm
<cfscript>
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
headers : {
keys: "Authorization",
values: "value"
}
});
generateGraphQLModels();
queryObj=gqlClient.subscribe("TripsBookedSub",{})
// writeDump(queryObj)
</cfscript>mutation Login($email: String) {
login(email: $email) {
token
}
}<cfscript>
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
//"raw_http_client": true,
headers : {
keys: "key",
values: "value"
}
});
generateGraphQLModels();
queryObj = gqlClient.mutation("Login", {
"email": "user1@example.com"
});
// writedump(queryObj)
response=queryObj.execute()
// writeDump(response.get("Data"))
</cfscript>fragment EmpName on Employee {
firstName
lastName
}fragment launchFragment on Launch {
id
site
mission {
name
}
}
query LaunchDetailsFragment($id:ID!) {
launch(id: $id) {
# Usage of named fragment
...launchFragment
}
}<cfscript>
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
headers : {
keys: "key",
values: "value"
}
});
generateGraphQLModels();
queryObj = gqlClient.query("LaunchDetailsFragment", {"id": "50"});
// writedump(queryObj)
response=queryObj.execute()
// writeDump(response.get("Data"))
</cfscript><cfscript>
// get the graphQL service first
gqlClient = getGraphQLClient({
service_Url : " https://apollo-fullstack-tutorial.herokuapp.com/graphql ",
"raw_http_client": true,
headers : {
keys: "key",
values: "value"
}
});
paramValues = ${launchId: 1}; // define the values to be passed in the query
response = gqlclient.fetchResponse("
query TripsBooked($launchId: ID!) {
launch(id: $launchId) {
id
isBooked
mission {
name
}
}
}
",paramValues);
writeOutput(response.get("Data"))
</cfscript>teacher {
name
students (first:5) {
name
}
}
}students (limit:5, afterID:152) {
id
name
}"batching_configuration":{
"enabled": true, // whether to enable batching on a query, mutation, or subscription
"batch_interval_ms": 1000, // The interval (in milliseconds) between each call.
"max_batch_size": 2 //
}startBatchPollergqlClient.startBatchPoller() <cfscript>
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
//"raw_http_client": true,
headers : {
keys: "Authorization",
values: "a2FsbHVAZ21haWwuY29t"
},
"batching_configuration":{
"enabled": true,
"batch_interval_ms": 1000,
"max_batch_size": 2
}
});
generateGraphQLModels();
writedump(gqlClient)
queryObj = gqlClient.query("TripsBooked", {})
writedump(queryObj);
response=queryObj.execute()
writeDump(response.get("Data"))
// define the error and success closure functions
onSuccess = function(response) {
writeOutput("<br>Received Response from GraphQL Server----------<br>");
writeOutput(response.toString());
}
onError = function() {
writeOutput("<br>Error While Receiving Response from GraphQL Server<br>");
}
writeOutput("<br/>"& "Active calls count" & "<br/>")
writeOutput(gqlClient.activeCallsCount())
writeOutput("<br/>"& "Can be batched" & "<br/>")
gqlClient.startBatchPoller();
queryObj.canBeBatched(true)
</cfscript>stopBatchPollergqlClient.stopBatchPoller()<cfscript>
gqlClient = getGraphQLClient({
service_url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
//"raw_http_client": true,
headers : {
keys: "key",
values: "value"
},
"batching_configuration":{
"enabled": true,
"batch_interval_ms": 1000,
"max_batch_size": 2
}
});
generateGraphQLModels();
writedump(gqlClient)
queryObj = gqlClient.query("TripsBooked", {})
writedump(queryObj);
response=queryObj.execute()
writeDump(response.get("Data"))
// define the error and success closure functions
onSuccess = function(response) {
writeOutput("<br>Received Response from GraphQL Server----------<br>");
writeOutput(response.toString());
}
onError = function() {
writeOutput("<br>Error While Receiving Response from GraphQL Server<br>");
}
writeOutput("<br/>"& "Active calls count" & "<br/>")
writeOutput(gqlClient.activeCallsCount())
writeOutput("<br/>"& "Can be batched" & "<br/>")
gqlClient.startBatchPoller();
queryObj.canBeBatched(true)
gqlClient.stopBatchPoller();
</cfscript>query LaunchList {
launches {
cursor
hasMore
launches {
id
site
}
}
}fragment launchFragment on Launch {
id
site
mission {
name
}
}
query LaunchDetailsFragment($id:ID!) {
launch(id: $id) {
# Usage of named fragment
...launchFragment
}
}<cfscript>
gqlClient = getGraphQLClient({
service_Url : "https://apollo-fullstack-tutorial.herokuapp.com/graphql",
root_folder: "root",
//"raw_http_client": true,
headers : {
keys: "key",
values: "value"
},
"batching_configuration":{
"enabled": true,
"batch_interval_ms": 1000,
"max_batch_size": 2
}
});
generateGraphQLModels();
writedump(gqlClient)
queryObj = gqlClient.query("LaunchList",{cursor:"1583556631"});
writedump(queryObj);
response=queryObj.execute()
writeDump(response.get("Data"))
queryObj2 = gqlClient.query("LaunchList", {cursor:""});
queryObj3 = gqlClient.query("LaunchDetailsFragment",[id:"89"]);
response3=queryObj3.execute()
writeDump(response3.get("Data"))
//queryObj4 = gqlClient.query("LaunchDetailsFragment",[id:"90"]);
gqlClient.startBatchPoller();
queryObj.canBeBatched(true);
queryObj2.canBeBatched(true);
queryObj3.canBeBatched(true);
gqlClient.stopBatchPoller();
writeOutput("Completed");
</cfscript>