Steams / ra-data-hasura-graphql

React-admin data provider for Hasura GraphQL endpoints
MIT License
211 stars 33 forks source link

Add entries in m-n relation table #27

Open wald-tq opened 4 years ago

wald-tq commented 4 years ago

I want to add data to a m-n relation table.

App <-------> AppPermissions <-------------> Permission

For the insert I created format and parse functions to create the desired format for the mutation.

For the update I have to change the mutation to first delete all relations then add the relations.

Is this correct? Can I build something to simplify this use-case?

webdeb commented 4 years ago

In further versions of hasura, there will be nested updates api https://github.com/hasura/graphql-engine/pull/3852/files

akamit21 commented 4 years ago

I have to add data in many to many relationships with 3 tables stream, subject and stream_subject which is a reference table with stream_id and subject_id

<ReferenceArrayInput
    label='Subject'
    source='stream_subjects'
    reference='stream_subject'
>
    <ReferenceArrayInput
        label='Subject'
        source='subject_id'
        reference='subject'
    >
        <AutocompleteArrayInput />
    </ReferenceArrayInput>
</ReferenceArrayInput>`

but getting error

{
  "errors": [
    {
      "extensions": {
        "path": "$.variableValues.objects[0].stream_subjects",
        "code": "validation-failed"
      },
      "message": "expecting a JSON object"
    }
  ]
}

I need to customize this

const buildCreateVariables = (resource, aorFetchType, params, queryType) => {
    return params.data;
};

function but not able to pass the required params, so I can make as desired query variable. Can anyone help me out how can send custom params to it?

wald-tq commented 4 years ago

Sorry, I can't help you with your problem.

We don't regret switching early from our plan using react-admin to building a custom admin interface with material-table and react-final-form. There were too many workarounds and ugly configurations to make hasura work with react-admin for our taste.

cpursley commented 4 years ago

I haven't tried it by maybe this library could help: https://github.com/mihaildu/ra-resource-aggregator