graphile / starter

Opinionated SaaS quick-start with pre-built user account and organization system for full-stack application development in React, Node.js, GraphQL and PostgreSQL. Powered by PostGraphile, TypeScript, Apollo Client, Graphile Worker, Graphile Migrate, GraphQL Code Generator, Ant Design and Next.js
https://graphile-starter.herokuapp.com
Other
1.74k stars 219 forks source link

Error when using patch in mutation. #264

Closed libinvarkey closed 3 years ago

libinvarkey commented 3 years ago

[[GraphQLError: Field "UpdateDmsPhysicalRwTblServiceAdvisorInput.nodeId" of required type "ID!" was not provided.], [GraphQLError: Field "UpdateDmsPhysicalRwTblServiceAdvisorInput.dmsPhysicalRwTblServiceAdvisorPatch" of required type "DmsPhysicalRwTblServiceAdvisorPatch!" was not provided.], [GraphQLError: Field "patch" is not defined by type "UpdateDmsPhysicalRwTblServiceAdvisorInput".], [GraphQLError: Field "id" is not defined by type "UpdateDmsPhysicalRwTblServiceAdvisorInput".]]

@benjie

benjie commented 3 years ago

The error tells you what’s wrong: your queries are invalid. Use the GraphiQL interface to learn what fields are available/required. Please follow the issue template in future.

libinvarkey commented 3 years ago

In my test test ,i passed the id but it shows Field "UpdateDmsPhysicalRwTblServiceAdvisorInput.nodeId" of required type "ID!" was not provided ("allDmsPhysicalRoVwStoreMasters", async () => { //const data = GetDashboardItemsData; await RunGraphQLQuery( // GraphQL query goes here: mutation updatePayTypeMaster( $id: Int! $pay_type: String $pay_type_code: String $department: String $store_id: String ) { updateDmsPhysicalRwPayTypeMaster( input: { patch: { payType: $pay_type payTypeCode: $pay_type_code department: $department storeId: $store_id } id: $id } ) { dmsPhysicalRwPayTypeMaster { id } } } , // GraphQL variables: {

    id: 34,
    Pay_type: 'test',
    pay_type_code: 'CH',
    department: 'REPAIR',
    store_id: '34567'
},
// Additional props to add to `req` (e.g. `user: {session_id: '...'}`)
{},
// This function runs all your test assertions:
async (json) => {

  expect(json.errors).toBeFalsy();
  expect(json.data).toBeTruthy();
  expect(json.data.allDmsPhysicalRoVwStoreMasters.totalCount).toBe(2);
  // expect(json.data.currentUser).toMatchObject({
  //     id: user.id,
  // });
}

); }); @benjie

benjie commented 3 years ago

The operation is not valid, because the field UpdateDmsPhysicalRwTblServiceAdvisorInput.nodeId (which was expecting an ID!) was not provided. You've passed id: $id whereas the mutation is expecting nodeId: ...; if you copy it into GraphiQL as I've instructed then it will show you where the error is. You're using the wrong mutation; you want something like updateDmsPhysicalRwPayTypeMasterById - have a look in GraphiQL to determine which mutation you need for the inputs you have available.