hasura / hasura/graphql-engine

Engine: check object type fields against data connector scalar types

Open
#10,418 0 comments 0 reactions 0 assignees View on GitHub
c/v3-engine ddnbugbounty-2024 k/v3-bug p/high
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
![image](https://github.com/user-attachments/assets/fd6c9808-6c1e-4b35-84c2-4fa18b3bcd16)

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
![image](https://github.com/user-attachments/assets/7889700d-2da0-4740-8ca8-41d038ad6dd1)
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)
![image](https://github.com/user-attachments/assets/aedcc805-78d6-4e82-9d3c-a3e5a646564e)

### Screenshots or Screencast
![image](https://github.com/user-attachments/assets/517bfa9e-ea30-42fa-bb67-ea50be63e692)
![image](https://github.com/user-attachments/assets/cfbbda41-8e67-4738-ba0d-aa3d9b6a4bfb)

### Please provide any traces or logs that could help here.

### Any possible solutions/workarounds you're aware of?

### Keywords

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.