Попытка отфильтровать запрос graphQL в appsync по enum - PullRequest
0 голосов
/ 11 мая 2019

Я работаю над приложением для Android в AWS Appsync, в котором перечислено около 40 000 компонентов.Ингредиенты имеют имя, идентификационный номер, популярность и (здесь интересный) список того, веганы они или нет, без глютена или нет.Я хотел бы иметь возможность запрашивать только те ингредиенты, которые являются веганскими, а не веганскими или имеют неизвестный веганский статус.Проблема в том, что я не вижу никакого способа добавить перечисление в «TableIngredientFilterInput».Есть ли способ отфильтровать по enum?Или преобразовать перечисление в строку и найти его среди других перечислений по имени / строке?

Моя схема:

input CreateIngredientInput {
    name: String!
    vegan: Vegan!
    glutenfree: GlutenFree!
    popularity: Int
}

input DeleteIngredientInput {
    name: String!
}

enum GlutenFree {
    GLUTENFREE
    CONTAINS_GLUTEN
    UNKNOWN
}

type Ingredient {
    name: String!
    id: ID
    vegan: Vegan
    glutenfree: GlutenFree
    popularity: Int
}

type IngredientConnection {
    items: [Ingredient]
    nextToken: String
}

type Mutation {
    createIngredient(input: CreateIngredientInput!): Ingredient
    batchCreateIngredients(input: [CreateIngredientInput]): IngredientConnection
    updateIngredient(input: UpdateIngredientInput!): Ingredient
    deleteIngredient(input: DeleteIngredientInput!): Ingredient
}

type Query {
    getIngredient(name: String!): Ingredient
    listIngredients(filter: TableIngredientFilterInput, limit: Int, nextToken: String): IngredientConnection
}

type Subscription {
    onCreateIngredient(
        name: String,
        id: ID,
        vegan: Vegan,
        glutenfree: GlutenFree,
        popularity: Int
    ): Ingredient
        @aws_subscribe(mutations: ["createIngredient"])
    onUpdateIngredient(
        name: String,
        id: ID,
        vegan: Vegan,
        glutenfree: GlutenFree,
        popularity: Int
    ): Ingredient
        @aws_subscribe(mutations: ["updateIngredient"])
    onDeleteIngredient(
        name: String,
        id: ID,
        vegan: Vegan,
        glutenfree: GlutenFree,
        popularity: Int
    ): Ingredient
        @aws_subscribe(mutations: ["deleteIngredient"])
}

input TableBooleanFilterInput {
    ne: Boolean
    eq: Boolean
}

input TableFloatFilterInput {
    ne: Float
    eq: Float
    le: Float
    lt: Float
    ge: Float
    gt: Float
    contains: Float
    notContains: Float
    between: [Float]
}

input TableIDFilterInput {
    ne: ID
    eq: ID
    le: ID
    lt: ID
    ge: ID
    gt: ID
    contains: ID
    notContains: ID
    between: [ID]
    beginsWith: ID
}

input TableIngredientFilterInput {
    name: TableStringFilterInput
    id: TableIDFilterInput
    popularity: TableIntFilterInput
}

input TableIntFilterInput {
    ne: Int
    eq: Int
    le: Int
    lt: Int
    ge: Int
    gt: Int
    contains: Int
    notContains: Int
    between: [Int]
}

input TableStringFilterInput {
    ne: String
    eq: String
    le: String
    lt: String
    ge: String
    gt: String
    contains: String
    notContains: String
    between: [String]
    beginsWith: String
}

input UpdateIngredientInput {
    name: String!
    id: ID
    vegan: Vegan
    glutenfree: GlutenFree
    popularity: Int
}

enum Vegan {
    VEGAN
    NON_VEGAN
    UNKNOWN
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...