OData / Microsoft Graph

This handler allows you to load remote OData metadata/schema as GraphQL Schema.
To get started, install the handler library:
yarn add @graphql-mesh/odataNow, you can use it directly in your Mesh config file:
sources:
- name: TripPin
handler:
odata:
baseUrl: https://services.odata.org/TripPinRESTierService/Dynamic Header Values
Mesh can take dynamic values from the GraphQL Context or the environmental variables. For example, if you use mesh dev or mesh start, GraphQL Context will be the incoming HTTP request.
The expression inside dynamic values should be as in JS.
From Context (HTTP Header for mesh dev or mesh start)
sources:
- name: MyGraphQLApi
handler:
odata:
baseUrl: https://graph.microsoft.com/v1.0
operationHeaders:
# Please do not use capital letters while getting the headers
Authorization: Bearer {context.headers['x-my-api-token']}
# You can also access to the cookies like below;
# Authorization: Bearer {context.cookies.myApiToken}And for mesh dev or mesh start, you can pass the value using x-my-graphql-api-token HTTP header.
From Environmental Variable
MY_API_TOKEN is the name of the environmental variable you have the value.
sources:
- name: MyGraphQLApi
handler:
odata:
baseUrl: https://graph.microsoft.com/v1.0
operationHeaders:
Authorization: Bearer {env.MY_API_TOKEN}Codesandbox Example
You can check out our TripPin example that uses the OData handler.
Config API Reference
baseUrl(type:String, required) - Base URL for OData APImetadata(type:String) - Custom $metadata File or URLoperationHeaders(type:JSON) - Headers to be used with the operation requestsschemaHeaders(type:JSON) - Headers to be used with the $metadata requestsbatch(type:String (multipart | json)) - Enable batchingexpandNavProps(type:Boolean) - Use $expand for navigation props instead of seperate HTTP requests (Default: false)
Last updated on July 27, 2022