I’m querying a specific commit via GraphQL API and getting commit: null

Hi @alex, I’m querying a specific commit via GraphQL API and getting commit: null in the response, even though the stream is found and the commit is visible in the web UI.
Stream ID: 578ded0a09
Commit ID:d6a11c4491
PAT ID (prefix): 9a5d05816a
This PAT has all scopes granted.
My user is Owner of the stream, and the stream is Link Shareable. Could you please investigate why the commit might not be resolving via the GraphQL API for this token/commit combination? This also causes UrlHelper.getResourceUrls() in @speckle/viewer` to fail. thanks.

Hi @lucas_barbosa

Please could you send us the query string you are using?

for the project id (stream) you give I don’t see any versions (commit) with the id you list here - this is certainly a reason why you might see null

hi @Jedd,
I’m experiencing an issue where the GraphQL API returns commit: null when I query for a specific commit, even though the stream itself is found and the commit is visible in the Speckle web UI.

Stream ID: 578ded0a09
Commit ID I am testing with: 27ad4f5fdd
Model URL (works in UI): https://app.speckle.systems/projects/578ded0a09/models/27ad4f5fdd

This PAT has all scopes granted.
i’m is the Owner of the stream 578ded0a09.
The stream is Link Shareable.
I do see a commit (ID: 71be079001, referencedObject: 4ee56207a20f8c4971c334a5629d32e7). If I query that commit ID 71be079001 directly using the first query structure, it does return the commit data and its referencedObject.

This suggests the issue might be specific to how commit 27ad4f5fdd (and a previous one I tested, d6a11c4491) are being resolved by the GraphQL API, as another commit in the same stream works.

This commit: null result also causes UrlHelper.getResourceUrls() in my @speckle/viewer implementation to fail with TypeError: Cannot read properties of null (reading ‘referencedObject’).

Could you please investigate why commit 27ad4f5fdd in stream 578ded0a09 might be returning commit: null via the API under these conditions?

Sorry if it was confusing, I don’t speak English well. Thank you for your assistance!

As per the url you posted the id is for the model and not the version.

For your posted URL i navigated to the latest version. This used to be called a commit

https://app.speckle.systems/projects/578ded0a09/models/27ad4f5fdd@2ce092772f

So from you link to a model version that does exist:

  • Project ID (formerly stream) = 578ded0a09
  • Model ID (formerly branch) = 27ad4f5fdd
  • Version ID (formerly commit) = 2ce092772f

hence the query you are attempting should instead be:

BUT - as per the squiggles beneath stream and commit this query is deprecated - as alluded to by use of “formerly”

Instead you can use either:

# for a specific version
query Project($projectId: String!, $modelId: String!, $versionId: String!) {
  project(id: $projectId) {
    id
    name
    model(id: $modelId) {
      version(id: $versionId) {
        id
        message
        referencedObject
      } } } }

OR

# for the latest version of a model
query Project($projectId: String!, $modelId: String!) {
  project(id: $projectId) {
    id
    name
    model(id: $modelId) {
      versions(limit: 1) {
        items {
          id
          message
          referencedObject
        } } } }
}

Apologies if you are using old reference material or tutorials but we have been making the transition away from streams and commits for about 2 years - can you describe what you are using as reference material and I’ll make sure it is on the list to be refreshed.

Also, @lucas_barbosa, I recommend you use https://app.speckle.systems/graphql in place of https://app.speckle.systems/explorer; the API documentation and query building are far superior.

2 Likes

I got it with your help @jonathon, thank you very much. :grin:

1 Like