Error Handling
The First Street API will return HTTP 200
for all valid requests to the API. Valid requests are any queries that satisfy type requirements within the GraphQL schema. Valid requests may or may not yield data and may or many not contain field errors.
When making a successful request to the GraphQL API, an object is returned:
Where data
represents the requested query that is provided. In cases where there is an error, an error
field will appear. This field is an array of an Error Message
:
In the event of a field specific error, data
will still resolve with the query result and errors
will be populated with an error message.
Error Message
Error message are standardized objects that returned in the event of an error. All keys may be optional so they may or may not be returned, depending on the error.
Key | Type | Description |
---|---|---|
message |
| A user friendly error message |
locations |
| An array that defines the |
extensions |
| Internal code of why the request could have failed |
path |
| An array that explains which part of the query the error occured on |
Example - Successful Error
A typical error you may receive is node-specific access, where access to a specific field within the API may not be granted due to contractual obligations. Consider the following query:
This query asks for a floodFactor
and heatFactor
for a particular property. In the event that the user requesting this information does not have access to heatFactor
, the following response will be returned:
message
describes the issue while path
provides an array of strings that maps where the query could have possibly failed. In this example the query that should be removed is heat { heatFactor }
because the user does not have access to the fields. Alternatively, you may email api@firststreet.org if you believe this field should be enabled for your account.
Example - Malformed Query
In the event of malformed queries, where queries are not following the GraphQL schema, HTTP 422
will occur. Consider the following query:
Because riskDirection
does not exist within the property.heat
field, the query is unprocessable. The following error will be returned:
In this scenario, data
will be completely null and the response is considered invalid. Please double check queries before sending another request.
Last updated