Skip to main content
Practitioner ⭐️⭐️⭐️
November 3, 2023
Solved

Get access to GraphQL through python SDK

  • November 3, 2023
  • 3 replies
  • 158 views

As Data Engineer I need access to GraphQL through python SDK

  • to modify Data Models GraphQL: to update versions of imported views from different Data Models
  • to read Data Models GraphQL: to parse specific info that I can not get through python SDK. For example
    • check if view was imported
    • what the source of imported view
Best answer by Dimitry Hoff

Hi,
Have you tried using existing GraphQL client libraries in python, for example
https://pypi.org/project/python-graphql-client/

It should work "out of the box", provided with a URL to GraphQL endpoint and Bearer Token for authentication.

GraphQL endpoint url can be found in Data Modeling UI, if you click on the URL button.
As for Bearer Token it is the same token that is used to authenticate to CDF (see https://developer.cognite.com/sdks/python/python_auth_oidc) and can be acquired with msal (already installed with cognite-sdk) and

3 replies

Practitioner ⭐️⭐️⭐️
November 6, 2023

Hi,
Have you tried using existing GraphQL client libraries in python, for example
https://pypi.org/project/python-graphql-client/

It should work "out of the box", provided with a URL to GraphQL endpoint and Bearer Token for authentication.

GraphQL endpoint url can be found in Data Modeling UI, if you click on the URL button.
As for Bearer Token it is the same token that is used to authenticate to CDF (see https://developer.cognite.com/sdks/python/python_auth_oidc) and can be acquired with msal (already installed with cognite-sdk) and

Practitioner ⭐️⭐️⭐️
November 8, 2023

Thank you

Anita Hæhre
Expert ⭐️⭐️⭐️⭐️
Head of Community
November 9, 2023

@almir.mavliutov thanks for your questions! We hope @Dimitry Hoff’s reply helped. We’ll convert this thread into a question, please do reach out should you have further questions or thoughts. 

Anita Hæhre