diff --git a/test/resources/annotations/srv/protocols.cds b/test/resources/annotations/srv/protocols.cds index c4d0947..654d423 100644 --- a/test/resources/annotations/srv/protocols.cds +++ b/test/resources/annotations/srv/protocols.cds @@ -1,47 +1,49 @@ -service NotAnnotated { +context protocols { entity A { key id : UUID; } } +service NotAnnotated { + entity A as projection on protocols.A; +} + @protocol: 'none' service AnnotatedWithAtProtocolNone { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; } @protocol: 'odata' service AnnotatedWithNonGraphQL { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; } @graphql service AnnotatedWithAtGraphQL { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; } @protocol: 'graphql' service AnnotatedWithAtProtocolString { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; } @protocol: ['graphql'] service AnnotatedWithAtProtocolStringList { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; } @protocol: [{kind: 'graphql'}] service AnnotatedWithAtProtocolObjectList { - entity A { - key id : UUID; - } + entity A as projection on protocols.A; +} + +@protocol: { graphql } +service AnnotatedWithAtProtocolObjectWithKey { + entity A as projection on protocols.A; +} + +@protocol: { graphql: 'dummy' } +service AnnotatedWithAtProtocolObjectWithKeyAndValue { + entity A as projection on protocols.A; } diff --git a/test/schemas/annotations.gql b/test/schemas/annotations.gql index 9918197..690bd97 100644 --- a/test/schemas/annotations.gql +++ b/test/schemas/annotations.gql @@ -66,6 +66,74 @@ type AnnotatedWithAtProtocolObjectList_input { A: AnnotatedWithAtProtocolObjectList_A_input } +type AnnotatedWithAtProtocolObjectWithKey { + A(filter: [AnnotatedWithAtProtocolObjectWithKey_A_filter], orderBy: [AnnotatedWithAtProtocolObjectWithKey_A_orderBy], skip: Int, top: Int): AnnotatedWithAtProtocolObjectWithKey_A_connection +} + +type AnnotatedWithAtProtocolObjectWithKeyAndValue { + A(filter: [AnnotatedWithAtProtocolObjectWithKeyAndValue_A_filter], orderBy: [AnnotatedWithAtProtocolObjectWithKeyAndValue_A_orderBy], skip: Int, top: Int): AnnotatedWithAtProtocolObjectWithKeyAndValue_A_connection +} + +type AnnotatedWithAtProtocolObjectWithKeyAndValue_A { + id: ID +} + +input AnnotatedWithAtProtocolObjectWithKeyAndValue_A_C { + id: ID +} + +type AnnotatedWithAtProtocolObjectWithKeyAndValue_A_connection { + nodes: [AnnotatedWithAtProtocolObjectWithKeyAndValue_A] + totalCount: Int +} + +input AnnotatedWithAtProtocolObjectWithKeyAndValue_A_filter { + id: [ID_filter] +} + +type AnnotatedWithAtProtocolObjectWithKeyAndValue_A_input { + create(input: [AnnotatedWithAtProtocolObjectWithKeyAndValue_A_C]!): [AnnotatedWithAtProtocolObjectWithKeyAndValue_A] + delete(filter: [AnnotatedWithAtProtocolObjectWithKeyAndValue_A_filter]!): Int +} + +input AnnotatedWithAtProtocolObjectWithKeyAndValue_A_orderBy { + id: SortDirection +} + +type AnnotatedWithAtProtocolObjectWithKeyAndValue_input { + A: AnnotatedWithAtProtocolObjectWithKeyAndValue_A_input +} + +type AnnotatedWithAtProtocolObjectWithKey_A { + id: ID +} + +input AnnotatedWithAtProtocolObjectWithKey_A_C { + id: ID +} + +type AnnotatedWithAtProtocolObjectWithKey_A_connection { + nodes: [AnnotatedWithAtProtocolObjectWithKey_A] + totalCount: Int +} + +input AnnotatedWithAtProtocolObjectWithKey_A_filter { + id: [ID_filter] +} + +type AnnotatedWithAtProtocolObjectWithKey_A_input { + create(input: [AnnotatedWithAtProtocolObjectWithKey_A_C]!): [AnnotatedWithAtProtocolObjectWithKey_A] + delete(filter: [AnnotatedWithAtProtocolObjectWithKey_A_filter]!): Int +} + +input AnnotatedWithAtProtocolObjectWithKey_A_orderBy { + id: SortDirection +} + +type AnnotatedWithAtProtocolObjectWithKey_input { + A: AnnotatedWithAtProtocolObjectWithKey_A_input +} + type AnnotatedWithAtProtocolString { A(filter: [AnnotatedWithAtProtocolString_A_filter], orderBy: [AnnotatedWithAtProtocolString_A_orderBy], skip: Int, top: Int): AnnotatedWithAtProtocolString_A_connection } @@ -147,6 +215,8 @@ input ID_filter { type Mutation { AnnotatedWithAtGraphQL: AnnotatedWithAtGraphQL_input AnnotatedWithAtProtocolObjectList: AnnotatedWithAtProtocolObjectList_input + AnnotatedWithAtProtocolObjectWithKey: AnnotatedWithAtProtocolObjectWithKey_input + AnnotatedWithAtProtocolObjectWithKeyAndValue: AnnotatedWithAtProtocolObjectWithKeyAndValue_input AnnotatedWithAtProtocolString: AnnotatedWithAtProtocolString_input AnnotatedWithAtProtocolStringList: AnnotatedWithAtProtocolStringList_input } @@ -154,6 +224,8 @@ type Mutation { type Query { AnnotatedWithAtGraphQL: AnnotatedWithAtGraphQL AnnotatedWithAtProtocolObjectList: AnnotatedWithAtProtocolObjectList + AnnotatedWithAtProtocolObjectWithKey: AnnotatedWithAtProtocolObjectWithKey + AnnotatedWithAtProtocolObjectWithKeyAndValue: AnnotatedWithAtProtocolObjectWithKeyAndValue AnnotatedWithAtProtocolString: AnnotatedWithAtProtocolString AnnotatedWithAtProtocolStringList: AnnotatedWithAtProtocolStringList } diff --git a/test/tests/annotations.test.js b/test/tests/annotations.test.js index 629ef23..e3ec8ad 100644 --- a/test/tests/annotations.test.js +++ b/test/tests/annotations.test.js @@ -123,5 +123,37 @@ describe('graphql - annotations', () => { const response = await POST(path, { query }) expect(response.data).not.toHaveProperty('errors') }) + + test('service annotated with "@protocol: { graphql }" is served at configured path', async () => { + const query = gql` + { + AnnotatedWithAtProtocolObjectWithKey { + A { + nodes { + id + } + } + } + } + ` + const response = await POST(path, { query }) + expect(response.data).not.toHaveProperty('errors') + }) + + test('service annotated with "@protocol: { graphql: \'dummy\' }" is served at configured path', async () => { + const query = gql` + { + AnnotatedWithAtProtocolObjectWithKeyAndValue { + A { + nodes { + id + } + } + } + } + ` + const response = await POST(path, { query }) + expect(response.data).not.toHaveProperty('errors') + }) }) })