Use One Model GraphQL

JFrog REST APIs

Content Type
REST API

Using One Model, you can access all supported domains using the following unified endpoint:

POST <your-jfrog-domain>/onemodel/api/v1/graphql

Note

JFrog One Model GraphQL currently supports the POST with JSON format. For more information, see the GraphQL documentation for Request Format and Response Format.

To use the One Model endpoint, execute your query using curl or an API client application such as Postman- see some simple examples below. For more information on queries and parameters you can use, see the One Model sections for the supported domains:

Usage Examples

Query Example

Use the following query to get the first 5 evidences from the repository “example-repo-local”:

query {
  evidence {
    searchEvidence(first: 5, where: {
        hasSubjectWith: {
          repositoryKey: "example-repo-local", 
          path: "path/to", 
          name: "file.ext"}}) {
      edges {
        node {
          predicateSlug
          predicateType
          predicate
          verified
          downloadPath
          subject {
            path
            name
          }
        }
      }
    }
  }
}

curl Example

Use the following curl command to execute a query:

curl --location -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" https://johnf.jfrog.io/onemodel/api/v1/graphql -d '{"query":"query { evidence { searchEvidence( first: 5, where: { hasSubjectWith: { repositoryKey: \"example-repo-local\" } } ) { totalCount } } }"}'

Best Practices

We recommend the following best practices when using GraphQL:

Use Pagination for Large Result Sets

Always specify first and use the after cursor for subsequent pages to handle large result sets efficiently. For more information about pagination, see One Model GraphQL Common Patterns and Conventions.

Focus Requests on the Fields You Require

The power of GraphQL is the ability to define exactly what information you want returned for each request. Request only the fields you need to minimize response size and improve query performance.

Use Filters to Narrow Results

Apply filtering criteria (for example, 'where' arguments) directly in the query instead of fetching large datasets and filtering them in the application layer.

Use Variables for Dynamic Queries

Define variables for dynamic values to make queries cleaner and reusable, as shown in the following example:

query GetEvidence($repoKey: String!, $path: String!, $name: String!) {
  evidence {
    getEvidence(
      repositoryKey: $repoKey
      path: $path
      name: $name
    ) {
      id
      verified
    }
  }
}