Reduced number of Salesforce API calls per GraphQL query

Aug 17th, 2021

We updated our GraphQL engine to be a bit smarter about how it generates the requests it sends to Salesforce. Some GraphQL queries that required multiple round trips to the Salesforce API will now generate a single, efficient SOQL query.

Staying under the Salesforce API rate limit can be a frustrating experience. OneGraph is constantly improving in the background to make it easier.

The average number of requests per GraphQL query after this change dropped from 2.3 to 1.4.

image

Typescript definitions for OneGraph Auth and better errors

Aug 12th, 2021

The onegraph-auth npm package now comes with Typescript definitions. Grab version 4.0.2 from npm.

Learn more about how to use onegraph-auth in your app in the OneGraph docs.

See what changes triggered a Salesforce update subscription

Aug 5th, 2021

There is a new changeList field in update subscription payloads for Salesforce. The field will list the fields that changed in the update and their values before and after the update.

For example, if you have the following subscription to Opportunity updates

subscription OpportunitySubscription {
  salesforce {
    opportunityUpdated {
      opportunity {
        id
        stageName
      }
      oldOpportunity {
        id
        stageName
      }
      changeList {
        field
        newValue
        oldValue
        fieldName
      }
    }
  }
}

and the stage for the opportunity is updated, you'll see a list of all of the changed fields on the Opportunity

{
  "data": {
    "salesforce": {
      "opportunityUpdated": {
        "changeList": [
          {
            "field": "PROBABILITY",
            "newValue": 90,
            "oldValue": 75,
            "fieldName": "probability"
          },
          {
            "field": "STAGE_NAME",
            "newValue": "Negotiation/Review",
            "oldValue": "Proposal/Price Quote",
            "fieldName": "stageName"
          },        
          {
            "field": "LAST_STAGE_CHANGE_DATE",
            "newValue": "2021-08-05T19:06:58.000+0000",
            "oldValue": "2021-08-05T19:00:41.000+0000",
            "fieldName": "lastStageChangeDate"
          },
          {
            "field": "SYSTEM_MODSTAMP",
            "newValue": "2021-08-05T19:06:58.000+0000",
            "oldValue": "2021-08-05T19:00:41.000+0000",
            "fieldName": "systemModstamp"
          },
          {
            "field": "LAST_MODIFIED_DATE",
            "newValue": "2021-08-05T19:06:58.000+0000",
            "oldValue": "2021-08-05T19:00:41.000+0000",
            "fieldName": "lastModifiedDate"
          }
        ],
        "opportunity": {
          "id": "0062100000DxkgLAAR",
          "stageName": "Negotiation/Review"
        },
        "oldOpportunity": {
          "id": "0062100000DxkgLAAR",
          "stageName": "Proposal/Price Quote"
        }
      }
    }
  }
}

Did you know that the probability automatically updates with the stage? I didn't, but now I do!

Custom fields that have not been mapped by OneGraph will have the special ANY_CUSTOM_FIELD enum value as their field, and the fieldName will match the name you see in the customFields field for the object. Go to the Architect tab of the OneGraph dashboard to set up a custom schema for your Salesforce instance that maps all custom fields to fields in the schema.

Read more about GraphQL subscriptions and Salesforce subscriptions in the docs.

Authenticate with test environments for Salesforce and Stripe

Aug 4th, 2021

Salesforce and Stripe both offer "test" authentication flows. These are separate environments with their own data that you can use while developing your integration.

OneGraph now has built-in support for authenticating with these test flows. You'll see new Salesforce [test] and Stripe [test] options in the Authentication dropdown in GraphiQL. They're also available when you create server-side tokens from the Server-Side Auth page.

If you're using onegraph-auth, our npm package, pass true as the third argument to login, e.g. auth.login('stripe', null, true), to log your users in with the test flow.

If you're manually constructing authentication URLs, add test=true as a query param to the /oauth/start url.

API metrics with rate limit info

Aug 4th, 2021

There is new data in the extensions field that shows you aggregate information about the API requests OneGraph made to fulfill your GraphQL query.

We surface information about API rate limits for the services that provide it. If you've worked with the Salesforce API and Salesforce admins who are constantly fighting to keep under their API quota, then you know how valuable this is.

{
  "data": "...",
  "extensions": {
    "metrics": {
      "api": {
        "avoidedRequestCount": 0,
        "requestCount": 1,
        "totalRequestMs": 457,
        "byHost": [
          {
            "host": "na173.salesforce.com",
            "requestCount": 1,
            "totalRequestMs": 457,
            "rateLimit": {
              "limit": 15000,
              "remaining": null,
              "used": 1,
              "resetAt": null
            }
          }
        ]
      }
    }
  }
}

You can turn it off by adding show_metrics=false as a query param to your URL.

Much of this information is also available with our Honeycomb integration.

Salesforce GraphQL Subscriptions package updated to support Contacts

Jul 29th, 2021

Our Salesforce package has been updated to support contacts.

Go grab our free OneGraph GraphQL Subscriptions package on the AppExchange store.

We support subscriptions to common Salesforce sobjects through the package and can support any sobject through a supplemental package. Contact sayhi@onegraph.com to get started.

Read more about Salesforce subscriptions and subscriptions on OneGraph in the docs.

Always-online persisted queries

Jul 23rd, 2021

There is a new "Fallback on error" option when you create a persisted query. Use it to keep your queries online even when the underlying API is down or you hit a rate-limit.

To use it, you also need to add caching to the query.

You can create a persisted query from the Persisted Queries section of the OneGraph dashboard, or with a mutation:

mutation PersistQuery($query: String!, $appId: String!) {
  oneGraph {
    createPersistedQuery(
      input: {
        query: $query
        appId: $appId
        cacheStrategy: { timeToLiveSeconds: 600 }
        fallbackOnError: true
      }
    ) {
      persistedQuery {
        id
      }
    }
  }
}

Read more about persisted queries in the docs.

Send Subscription Delivery metrics to Honeycomb

Jun 27th, 2021

In addition to sending metrics for every API call OneGraph makes on your behalf, the Monitoring tab on the dashboard now supports sending subscription delivery metrics to Honeycomb.

Each event includes the following keys:

KeyTypedescription
destinationStringThe url of the webhook destination, or websocket
subscriptionIdStringThe id of the subscription
operationNameStringThe optional operationName of the subscription, e.g. GitHubRepoSubscription
statusCodeIntegerThe status code OneGraph received from your server, if it received a status code
webhookRequestMillisecondsIntegerThe time, in milliseconds, it took us to send the webhook POST request to the server
timedOutBooleantrue if the request timed out before we finished sending the webhook
truncatedResponseBodyStringThe first 512 bytes of the response from the server, if OneGraph did not receive a 2xx or a 410 status code

Send API metrics to Honeycomb

Jun 24th, 2021

There is a new page on the OneGraph dashboard dedicated to monitoring.

Our first monitoring feature will send metrics from the OneGraph service directly to your Honeycomb project.

Once configured, OneGraph will send an event to Honeycomb for each API call made while executing one of your GraphQL queries. The event will contain the following keys:

KeyTypeDescription
hostStringThe host, e.g. api.github.com
statusCodeIntegerThe HTTP status code, e.g. 200
methodStringThe HTTP method, e.g. GET

Monitoring page

Support for the updated sobjects API in Salesforce

Oct 16th, 2020

Use the new updatedSobjects field to keep track of the latest updates to your Salesforce data. Salesforce allows you to make requests for a range within the last 30 days.

The example below gets the last two leads that were updated or created this month:

query UpdatedLeadsQuery {
  salesforce {
    updatedSobjects(
      start: "2020-10-01T00:00:00+00:00"
      end: "2020-10-16T00:00:00+00:00"      
    ) {
      leads(last: 2) {
        latestDateCovered
        ids
        nodes {
          id
          name
          createdDate
        }
      }
    }
  }
}

Keep the Salesforce rate-limits in mind when you use this new field. The query will only use up one of your API calls if you only request the ids field. If you only request top-level fields for the objects through the nodes field (e.g. node.name), OneGraph will make one additional API request for every 500 objects. If you request nested fields (e.g. node.account.name), OneGraph will use up at least one API request per node.

Up to 600,000 nodes could be returned in a single query, so it's best to use the first or last arg to limit the number of API requests.

OneGraph also supports GraphQL subscriptions for Salesforce. Learn more about subscriptions in the docs.