# Using data from `moviedm` v1

Before getting started, make sure the data model and version is the one you want to develop on.

Here you will find the documentation on how to consume data within your data model.

You can do this via directly via GraphQL, Autogenerative-SDK for Python and JS/TS or 3rd party tools like GraphQL Code Generator .

## Using GraphQL directly

## #

The URL to access the data model is availble on:

You can access this URL as long as you also provide a valid Bearer token in the `Authorization` header of your request. We support both `POST` and `GET` requests to the GraphQL endpoint.

You can run directly query against this URL through any 3rd party tools like Postman, GraphIQL, PowerBI and Grafana. More documentation to come soon on this.

## JavaScript / TypeScript Autogenerated SDK

## #

Using the same CLI you ran to get this documentation up and running, you can also create a JS/TS SDK based on your data model.

The SDK is a great way to interact with data in your data model without learning GraphQL, as well it provides all the nicities of TypeScript typings for every query you run on the data model. Additionally, it generates all the TypeScript types for every type in your Data Model.

Requirements: You must be on node version 16.7 or above.

#### Getting started

#### #

`cdf data-model generate-js-sdk --dm="moviedm" --dm-v="1"`

By default, a `sample.ts` will be generated at `generated/` in your working directory. to skip this, feel free to add `--include-sample=false` at the end of your command.

Now you can import `FDMQueryClientBuilder` from `@cognite/fdm-client` like:

#### Authenticate with CDF

#### #

With the `FDMQueryClientBuilder` , you can create a client either:

1. from the default token (valid for around 30 minutes) from the CLI

1. or, instantiate with a `CogniteClient` from `@cognite/sdk` .

With the `client` now you can run any queries you see in this documentation via `client.runQuery({...})` .

Note that there's a build in variable called `everything` which will grab all "primitive" values, as shown in the example below.

#### Sample snippet

#### #

## Python Autogenerated SDK

## #

Using the same CLI you ran to get this documentation up and running, you can also create a Python SDK based on your data model.

The SDK is a great way to interact with data in your data model without learning GraphQL, as well it provides all the nicities of compile time checks for every query you run on the data model. As well, with the autogenerated SDK for Python, all commands are no longer camel case (i.e. listMovies) but instead converted to snake case (i.e. list_movies).

Requirements:

1. You must have Python 3 installed
2. You must have `sgqlc` and `CogniteClient` installed (`pip3 install sgqlc cognite-sdk` )

#### Getting started

#### #

`cdf data-model generate-python-sdk --dm="moviedm" --dm-v="1"`

By default, a `sample.python` will be generated at `generated/` in your working directory. to skip this, feel free to add `--include-sample=false` at the end of your command.

Now you can import `FDMQueryClient` from `generated/` , to change the folder that the client gets generated at, use the `--output-directory=XXX` .

You can import the client like:

#### Authenticate with CDF

#### #

With the `FDMQueryClientBuilder` , you can create a client either:

1. from the default token (valid for around 30 minutes) from the CLI

1. or, instantiate with Client ID and Client Secret (AzureAD only).

1. or, instantiate with a `CogniteClient` from `cognite-sdk` .

With the `client` now you can run any queries you see in this documentation via `query = client.start_query()` , declaring the query, and then `client.run_query(query)` to get the response.

#### Sample snippet

#### #

## GraphQL Code Generator

## #

Using GraphQL as a query language means it is compatible to many 3rd party tools that makes development simple and easy. One of these tools is the GraphQL Code Generator. This short guide will go over how to connect the generator tool with CDF.

After you have gone through the setup of the codegen and got `codegen.yml` setup, then the key point is to make sure the client is connected to CDF.

1. Make a file like the following, for this example we will name it `src/graphqlFetcher.ts` .

1. Then from the codegen config file (`codegen.yml` ), we have

Then you should have a working GraphQL Code Generator for your app.

Next - Actors

aggregateActors