I'm working on migrating an GraphQL app from using Postgraphql 3.10 with a Postgresql version 9.6 database to using postgraphile version 4.7.0 and a Postgresql version 11 database.
The graphql query below used to work in the old version but fail in the new version.
query supplier($id: Int!) {
supplierById(id: $id) {
id accountId
title intro description
imageBg imageProfile imageProfileRot
rating status
productsBySupplierId(condition: {published: true, deleted: false}) {
nodes {
id type prodTitle prodDescr
price currency duration { hours minutes }
}
}
reviewsBySupplierId(condition: {target: SUPPLIER}) {
nodes {comment rating createdAt}
}
}
}
The failure is because of the condition filter and the error message say:
"GraphQLError: Field \"published\" is not defined by type ProductCondition."
"GraphQLError: Field \"deleted\" is not defined by type ProductCondition."
"GraphQLError: Field \"target\" is not defined by type ReviewCondition."
I can't find any documentation about how to set up the database table to support this condition. Do I need to add the fields published, deleted and target to some index for postgraphile to support this condition?
Postgraphile config in express app
app.use( postgraphile( `postgres://${account}:${passwd}@localhost:5432/${database}`, schema, {
pgDefaultRole: '*****_anonymous',
dynamicJson: true,
jwtSecret: Buffer.from( secret, 'hex' ).toString(),
jwtPgTypeIdentifier: '*****.jwt_token',
enableCors: true,
disableQueryLog: false,
graphiql: config.web.graphiql,
graphqlRoute: config.web.graphql,
graphiqlRoute: '/qtest',
subscriptions: true,
watchPg: true,
setofFunctionsContainNulls: false,
ignoreRBAC: false,
ignoreIndexes: false,
showErrorStack: "json",
extendedErrors: ['severity', 'code', 'detail', 'hint', 'position', 'internalPosition', 'internalQuery', 'where', 'schema', 'table', 'column', 'dataType', 'constraint', 'file', 'line', 'routine'],
//extendedErrors: ["hint", "detail", "errcode"],
//appendPlugins: [require("@graphile-contrib/pg-simplify-inflector")],
exportGqlSchemaPath: "schema.graphql",
sortExport: true,
enhanceGraphiql: true,
allowExplain(req) {
// TODO: customise condition!
return true;
},
enableQueryBatching: true,
disableDefaultMutations:false,
legacyRelations: "omit"
} ) )