8. Introduction to Functions5. Importing Your Ontology Types

5 - Importing Your Ontology Types

This content is also available at learn.palantir.com ↗ and is presented here for accessibility purposes.

📖 Task Introduction

You will need to explicitly import your object types into your code repository before you can write functions against them. In this tutorial, you’ll be writing functions exclusively on your flight alert object type. This task will walk you through the process of importing the object type into your project.

🔨 Task Instructions

  1. Click the Settings menu item along the top of your application screen. Hint: it may be grouped under the More ▾ dropdown item.

  2. From the left-hand menu, click Ontology.

  3. Type the name of your Flight Alert object (e.g., [yourName] Flight Alert) into the Filter object types search bar in the Ontology Imports window.

  4. When your object type comes up in the search, copy the API name in the middle column (e.g., yourNameFlightAlert) to your clipboard.

  5. Click the sign to the right of your API name to import your object type into your project.

    • ℹ️ Once you import your object type into your repository, its available to other repositories in the same project. In other words, you’ll only need to perform an object type import once per project.
  6. Click the blue Save button in the bottom right of the window.

  7. Later, you’ll be referencing the passengers, flight alert ⟷ flight and flight ⟷ delays types, so let’s add them to your project, too.

    • Switch to the Link Types tab in the middle area of your screen, locate the link between your flight alert object and [Example Data] Flight, and add it by clicking the button.
  8. Do the same for the links between [Example Data] Flight and [Example Data] Delays and between your flight alert object and [Example Data] Passenger using the same steps as above, remembering to click Save on completion.

  9. When the screen reloads, return to the Code tab and open the ../src/index.ts file (i.e., not in the __tests__ folder).

  10. In the import statement on line 2, add in the API name you copied from the Ontology settings page into the empty curly braces. In this sample replace JmeierFlightAlert with your API: import { JmeierFlightAlert } from "@foundry/ontology-api";

If you need any assistance with the tasks above, consult this short description of the Ontology type importing process. Note particularly that you can ctrl + select on the @foundry/ontology-api package name to learn what Ontology types are available in your repository. If you do not see your API name in the list, check that it was properly imported in the Settings > Ontology section of your repo. If it is still not showing up, restart Code Assist and/or refresh your browser.