スキーマのカスタマイズ
Custom schemas are defined in configuration files. This chapter outlines the structure of these files.
Note: The GenerateSchemaFiles property enables you to persist table metadata in static schema files that are easy to customize (to persist your changes to column data types, for example). Set this property to "OnStart" to generate schema files for all tables in your database at connection.
Alternatively, set this property to "OnUse" to generate schemas as you execute SELECT queries to tables. It is also possible to create a specific schema file for a table using the CreateSchema stored procedure.
Editing Schema Files
Tables and views are defined by authoring schema files in APIScript. APIScript is a simple configuration language that allows you to define the columns and the behavior of the table. It also has built-in オペレーション that enable you to process GraphQL. In addition to these data processing primitives, APIScript is a full-featured language with constructs for conditionals, looping, etc. However, as shown by the example schema, for most table definitions you will not need to use these features.
Example Schema
Below is a fully functional table schema that models the Labels table and contains all the components you will need to execute SQL to GraphQL data sources.
You can find more information on each of the components of a schema in カラム定義, SELECT 実行.
<rsb:script xmlns:rsb="http://apiscript.com/ns?v1" xmlns:xs="http://www.cdata.com/ns/rsbscript/2" xmlns:other="http://apiscript.com/ns?v1">
<rsb:info title="Labels" desc="Lists information about the different labels you can apply on an issue." other:possiblePaths="{'path':'/repository/labels/edges/node','Name':{'path':'/repository/label'}}" other:paginationObjects="{'labels':{'cursorName':'after','cursorType':'String','pageSizeArgumentName':'first','pageSizeArgumentType':'Int','depth':'1','paginationType':'Cursor','isConnection':'True','pageInfo':['endCursor','hasNextPage','hasPreviousPage','startCursor']}}">
<attr name="Id" xs:type="string" key="true" other:relativePath="id" desc="The ID of the label." />
<attr name="RepositoryName" xs:type="string" other:relativePath="name" desc="The name of the repository." other:filter="name:=" other:argumenttype="String!" other:depth="1" references="Repositories.Name" />
<attr name="UserLogin" xs:type="string" desc="The login name of the user." other:filter="owner:=" other:argumenttype="String!" other:depth="1" references="Users.Login" other:mirror="true" other:canBeSliced="true" />
<attr name="Color" xs:type="string" other:relativePath="color" desc="Identifies the label color." />
<attr name="CreatedAt" xs:type="datetime" other:relativePath="createdAt" desc="Identifies the date and time when the label was created." other:orderby="CREATED_AT" />
<attr name="Description" xs:type="string" other:relativePath="description" desc="A brief description of this label." />
<attr name="IsDefault" xs:type="boolean" other:relativePath="isDefault" desc="Indicates whether or not this is a default label." />
<attr name="Name" xs:type="string" other:relativePath="name" desc="Identifies the label name." other:filter="name:=" other:argumenttype="String!" other:orderby="NAME" other:isPathFilter="true" />
<attr name="ResourcePath" xs:type="string" other:relativePath="resourcePath" desc="The HTTP path for this label." />
<attr name="UpdatedAt" xs:type="datetime" other:relativePath="updatedAt" desc="Identifies the date and time when the label was last updated." />
<attr name="Url" xs:type="string" other:relativePath="url" desc="The HTTP URL for this label." />
</rsb:info>
<rsb:script method="GET">
<rsb:push op="graphqladoSelect" />
</rsb:script>
</rsb:script>
Example Custom Headers
Static Headers
The following example shows how to add static headers in the schema file. These headers are added to the request every time the schema file is called.
<rsb:script xmlns:rsb="http://apiscript.com/ns?v1" xmlns:xs="http://www.cdata.com/ns/rsbscript/2" xmlns:other="http://apiscript.com/ns?v1">
...
<input name="Ship1" other:headerName="DynamicValuedHeader" />
<input name="Ship2" other:headerName="DynamicValuedHeader" />
</rsb:info>
<api:set attr="Header:Name#1" value="StaticValuedHeader" />
<api:set attr="Header:Value#1" value="StaticValuedHeader__Value" />
Dynamic Headers
The following example shows how to add dynamic headers in the schema file. These headers are added to the request every time the schema file is called.
<rsb:script xmlns:rsb="http://apiscript.com/ns?v1" xmlns:xs="http://www.cdata.com/ns/rsbscript/2" xmlns:other="http://apiscript.com/ns?v1">
...
<input name="Ship1" other:headerName="DynamicValuedHeader" />
<input name="Ship2" other:headerName="DynamicValuedHeader" />
<input name="Ship3" other:headerName="DynamicValuedHeader2" />
</rsb:info>
<api:set attr="Header:Name#1" value="DynamicValuedHeader" />
<api:set attr="Header:Value#1" value="[_input.Ship1] - [_input.Ship2]" />
SELECT * FROM [Table] WHERE [Ship1] = "Value1" AND [Ship2] = "Value2" AND [DynamicValuedHeader2] = "custom value"
In the above example, the value format of DynamicValuedHeader is parsed by the driver, but for DynamicValuedHeader2, it is the same as the value specified in the query.