Skip to content

Commit

Permalink
Merge branch 'main' into configurable-payload-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
schwma authored Jul 24, 2024
2 parents e0dd7c7 + 4b0cb2a commit 553685a
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 50 deletions.
2 changes: 1 addition & 1 deletion lib/resolvers/GraphQLRequest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')

class GraphQLRequest extends cds.Request {
constructor(args) {
Expand Down
11 changes: 1 addition & 10 deletions lib/resolvers/crud/create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const { INSERT } = cds.ql
const { ARGS } = require('../../constants')
const { getArgumentByName, astToEntries } = require('../parse/ast2cqn')
Expand All @@ -13,15 +13,6 @@ module.exports = async ({ req, res }, service, entity, selection) => {
const entries = entriesStructureToEntityStructure(service, entity, astToEntries(input))
query.entries(entries)

if (cds.env.features.cds_validate) {
const assertOptions = { mandatories: true }
const errs = cds.validate(entries, entity, assertOptions)
if (errs) {
if (errs.length === 1) throw errs[0]
throw Object.assign(new Error('MULTIPLE_ERRORS'), { statusCode: 400, details: errs })
}
}

const result = await service.dispatch(new GraphQLRequest({ req, res, query }))

return formatResult(entity, selection, result, false)
Expand Down
2 changes: 1 addition & 1 deletion lib/resolvers/crud/delete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const { DELETE } = cds.ql
const { ARGS } = require('../../constants')
const { getArgumentByName, astToWhere } = require('../parse/ast2cqn')
Expand Down
2 changes: 1 addition & 1 deletion lib/resolvers/crud/read.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const { SELECT } = cds.ql
const { ARGS, CONNECTION_FIELDS } = require('../../constants')
const { getArgumentByName, astToColumns, astToWhere, astToOrderBy, astToLimit } = require('../parse/ast2cqn')
Expand Down
11 changes: 1 addition & 10 deletions lib/resolvers/crud/update.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const { SELECT, UPDATE } = cds.ql
const { ARGS } = require('../../constants')
const { getArgumentByName, astToColumns, astToWhere, astToEntries } = require('../parse/ast2cqn')
Expand All @@ -24,15 +24,6 @@ module.exports = async ({ req, res }, service, entity, selection) => {
const entries = entriesStructureToEntityStructure(service, entity, astToEntries(input))
query.with(entries)

if (cds.env.features.cds_validate) {
const assertOptions = { mandatories: true }
const errs = cds.validate(entries, entity, assertOptions)
if (errs) {
if (errs.length === 1) throw errs[0]
throw Object.assign(new Error('MULTIPLE_ERRORS'), { statusCode: 400, details: errs })
}
}

let resultBeforeUpdate
const result = await service.tx(async tx => {
// read needs to be done before the update, otherwise the where clause might become invalid (case that properties in where clause are updated by the mutation)
Expand Down
2 changes: 1 addition & 1 deletion test/resources/bookshop-graphql/srv/test-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')

module.exports = cds.service.impl(srv => {
const { Foo } = srv.entities
Expand Down
2 changes: 1 addition & 1 deletion test/tests/annotations.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - annotations', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/concurrency.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - resolver concurrency', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/context.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - context is set', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/custom-error-formatter.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - custom error formatter function', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/custom-handlers.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - custom handlers', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/edge-cases.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - edge cases', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/error-handling-dev.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - error handling in development', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/error-handling-prod.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('graphql - error handling in production', () => {
process.env.NODE_ENV = 'production'
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/graphiql.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - GraphiQL', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/localized.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - queries with localized data', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/logger-dev.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - query logging in development', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')
const util = require('util')
Expand Down
2 changes: 1 addition & 1 deletion test/tests/logger-prod.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('graphql - query logging with sanitization in production', () => {
process.env.NODE_ENV = 'production'
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')
const util = require('util')
Expand Down
2 changes: 1 addition & 1 deletion test/tests/mutations/create.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - create mutations', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/mutations/delete.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - delete mutations', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/mutations/update.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - update mutations', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/aliases.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - aliases', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/filter.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - filter', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/fragments.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - fragments', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/meta.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - meta fields', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/orderBy.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - orderBy', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/paging-offset.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - offset-based paging', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/queries.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - queries', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/totalCount.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - queries with totalCount', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/queries/variables.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - variables', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/request.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('graphql - cds.request', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const { gql } = require('../util')

Expand Down
2 changes: 1 addition & 1 deletion test/tests/types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const _getMutationAndVariablesForFieldWithVariable = (field, value) => ({
})

describe('graphql - types parsing and validation', () => {
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
const path = require('path')
const fs = require('fs')

Expand Down

0 comments on commit 553685a

Please sign in to comment.