hasura / hasura/graphql-engine
Engine: check object type fields against data connector scalar types
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Component
c/v3-engine
### What is the current behaviour?
If the objectType.dataConnectorTypeMapping.fieldMapping.key (field defined on the objectType definiton) does not match with the dataConnectorObjectType's mapped field (the value of objectType.dataConnectorTypeMapping.fieldMapping.key.value) and querying the objectType's model using graphiql in the console will fail with unclear error.
### What is the expected behaviour?
If the types of mapped fields of the objectType and dataConnector objectType doesn't match the local build should fail with clear error message highlighting this invalid metadata rather than a sucessful build.
### How to reproduce the issue?
1. have a field say isCompleted in a table say invoice in your pg database with type boolean
2. do the necessary steps from from supergraph init to add all resources from the getting started guide
3. add resources step will create an Invoice.hml file with objectType looking like this

4. edit the objectType manually to the below form ( isCompleted field's type is changed to Int4) but the fieldMapping is now from isCompleted field of type Int4 to is_completed field of type Bool in the dataConnector objectType invoice

5. run the `ddn supergraph build local` command with apt flags
6. navigate to `https://console.hasura.io/local/graphql?url=http://localhost:3000`
7. query the model for which objectType definition has been edited accordingly(here it is app_invoice)

### Screenshots or Screencast


### Please provide any traces or logs that could help here.
### Any possible solutions/workarounds you're aware of?
### Keywords
Contributor guide
Research direction
Start in the c/v3-engine component and reproduce the mismatch using the objectType and dataConnectorObjectType mapping described in the issue. Run `ddn supergraph build local` with the edited Invoice metadata, then query the resulting model to confirm the current failure; done means the local build rejects mismatched scalar types with a clear validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgres, typescript
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100