如何使用graphql管理不同用户的属性的读取访问权限?

时间:2019-04-06 12:00:35

标签: node.js vue.js graphql aws-appsync

我正在研究graphql,但我是新手。我想管理任何用户都可以读取的不同用户属性的读取权限。架构如下:

type BadCustomer {
    id: ID!
    name: String!
    phone: AWSPhone
    email: AWSEmail
    streetAddress: String
    dob: AWSDate
    passportNumber: String
    driversLicenceNumber: String
    ipAddress: AWSIPAddress
    damages(
        filter: TableSubscriberFilterInput,
        sortDirection: ModelSortDirection,
        limit: Int,
        nextToken: String
    ): DamageConnection
}

type BadCustomerConnection {
    items: [BadCustomer]
    nextToken: String
}

input CreateBadCustomerInput {
    name: String!
    phone: AWSPhone
    email: AWSEmail
    streetAddress: String
    dob: AWSDate
    passportNumber: String
    driversLicenceNumber: String
    ipAddress: AWSIPAddress
}

input CreateDamageInput {
    damage: Float!
    comment: String
    customerId: ID!
    subscriberId: ID!
}

input CreateIndustryInput {
    name: String!
}

input CreateSubscriberInput {
    name: String!
    email: AWSEmail!
    phone: AWSPhone
    streetAddress: String!
    subscriberIndustryId: ID!
}

input CreateSubscriberQueriesInput {
    queries: Int!
    subscriberId: ID!
}

type Damage {
    id: ID!
    customer: BadCustomer!
    victim: Subscriber!
    damage: Float!
    comment: String
}

type DamageConnection {
    items: [Damage]
    nextToken: String
}

input DeleteBadCustomerInput {
    id: ID!
}

input DeleteDamageInput {
    id: ID!
}

input DeleteIndustryInput {
    id: ID!
}

input DeleteSubscriberInput {
    id: ID!
}

input DeleteSubscriberQueriesInput {
    id: ID!
}

type Industry {
    id: ID!
    name: String!
    subscribers(
        filter: TableSubscriberFilterInput,
        sortDirection: ModelSortDirection,
        limit: Int,
        nextToken: String
    ): SubscriberConnection
}

type IndustryConnection {
    items: [Industry]
    nextToken: String
}

enum ModelSortDirection {
    ASC
    DESC
}

type Mutation {
    createIndustry(input: CreateIndustryInput!): Industry
    updateIndustry(input: UpdateIndustryInput!): Industry
    deleteIndustry(input: DeleteIndustryInput!): Industry
    createSubscriber(input: CreateSubscriberInput!): Subscriber
    updateSubscriber(input: UpdateSubscriberInput!): Subscriber
    deleteSubscriber(input: DeleteSubscriberInput!): Subscriber
    createBadCustomer(input: CreateBadCustomerInput!): BadCustomer
    updateBadCustomer(input: UpdateBadCustomerInput!): BadCustomer
    deleteBadCustomer(input: DeleteBadCustomerInput!): BadCustomer
    createDamage(input: CreateDamageInput!): Damage
    updateDamage(input: UpdateDamageInput!): Damage
    deleteDamage(input: DeleteDamageInput!): Damage
    createSubscriberQueries(input: CreateSubscriberQueriesInput!): SubscriberQueries
    updateSubscriberQueries(input: UpdateSubscriberQueriesInput!): SubscriberQueries
    deleteSubscriberQueries(input: DeleteSubscriberQueriesInput!): SubscriberQueries
}

type Query {
    getIndustry(id: ID!): Industry
    listIndustries(filter: TableIndustryFilterInput, limit: Int, nextToken: String): IndustryConnection
    getSubscriber(id: ID!): Subscriber
    listSubscribers(filter: TableSubscriberFilterInput, limit: Int, nextToken: String): SubscriberConnection
    getBadCustomer(id: ID!): BadCustomer
    listBadCustomers(filter: TableBadCustomerFilterInput, limit: Int, nextToken: String): BadCustomerConnection
    getDamage(id: ID!): Damage
    listDamages(filter: TableDamageFilterInput, limit: Int, nextToken: String): DamageConnection
    findSubscriberByEmail(email: AWSEmail!): SubscriberConnection
    getSubscriberQueries(id: ID!): SubscriberQueries
    listSubscriberQueries(filter: TableSubscriberQueriesFilterInput, limit: Int, nextToken: String): SubscriberQueriesConnection
}

type Subscriber {
    id: ID!
    name: String!
    email: AWSEmail!
    password: String!
    phone: AWSPhone
    streetAddress: String!
    industry: Industry!
    damages(
        filter: TableSubscriberFilterInput,
        sortDirection: ModelSortDirection,
        limit: Int,
        nextToken: String
    ): DamageConnection
    queries: SubscriberQueries

}

type SubscriberConnection {
    items: [Subscriber]
    nextToken: String
}

type SubscriberQueries {
    id: ID!
    subscriber: Subscriber!
    queries: Int!
}

type SubscriberQueriesConnection {
    items: [SubscriberQueries]
    nextToken: String
}

type Subscription {
    onCreateIndustry(id: ID, name: String): Industry
        @aws_subscribe(mutations: ["createIndustry"])
    onUpdateIndustry(id: ID, name: String): Industry
        @aws_subscribe(mutations: ["updateIndustry"])
    onDeleteIndustry(id: ID, name: String): Industry
        @aws_subscribe(mutations: ["deleteIndustry"])
    onCreateSubscriber(
        id: ID,
        name: String,
        email: AWSEmail,
        phone: AWSPhone,
        streetAddress: String
    ): Subscriber
        @aws_subscribe(mutations: ["createSubscriber"])
    onUpdateSubscriber(
        id: ID,
        name: String,
        email: AWSEmail,
        phone: AWSPhone,
        streetAddress: String
    ): Subscriber
        @aws_subscribe(mutations: ["updateSubscriber"])
    onDeleteSubscriber(
        id: ID,
        name: String,
        email: AWSEmail,
        phone: AWSPhone,
        streetAddress: String
    ): Subscriber
        @aws_subscribe(mutations: ["deleteSubscriber"])
    onCreateBadCustomer(
        id: ID,
        name: String,
        phone: AWSPhone,
        email: AWSEmail,
        streetAddress: String
    ): BadCustomer
        @aws_subscribe(mutations: ["createBadCustomer"])
    onUpdateBadCustomer(
        id: ID,
        name: String,
        phone: AWSPhone,
        email: AWSEmail,
        streetAddress: String
    ): BadCustomer
        @aws_subscribe(mutations: ["updateBadCustomer"])
    onDeleteBadCustomer(
        id: ID,
        name: String,
        phone: AWSPhone,
        email: AWSEmail,
        streetAddress: String
    ): BadCustomer
        @aws_subscribe(mutations: ["deleteBadCustomer"])
    onCreateDamage(id: ID, damage: Float, comment: String): Damage
        @aws_subscribe(mutations: ["createDamage"])
    onUpdateDamage(id: ID, damage: Float, comment: String): Damage
        @aws_subscribe(mutations: ["updateDamage"])
    onDeleteDamage(id: ID, damage: Float, comment: String): Damage
        @aws_subscribe(mutations: ["deleteDamage"])
    onCreateSubscriberQueries(id: ID, queries: Int): SubscriberQueries
        @aws_subscribe(mutations: ["createSubscriberQueries"])
    onUpdateSubscriberQueries(id: ID, queries: Int): SubscriberQueries
        @aws_subscribe(mutations: ["updateSubscriberQueries"])
    onDeleteSubscriberQueries(id: ID, queries: Int): SubscriberQueries
        @aws_subscribe(mutations: ["deleteSubscriberQueries"])
}

input TableBadCustomerFilterInput {
    id: TableIDFilterInput
    name: TableStringFilterInput
    phone: TableStringFilterInput
    email: TableStringFilterInput
    streetAddress: TableStringFilterInput
    dob: TableStringFilterInput
    passportNumber: TableStringFilterInput
    driversLicenceNumber: TableStringFilterInput
    ipAddress: TableStringFilterInput
}

input TableBooleanFilterInput {
    ne: Boolean
    eq: Boolean
}

input TableDamageFilterInput {
    id: TableIDFilterInput
    damage: TableFloatFilterInput
    comment: TableStringFilterInput
}

input TableEventFilterInput {
    id: TableIDFilterInput
    name: TableStringFilterInput
    where: TableStringFilterInput
    when: TableStringFilterInput
    description: TableStringFilterInput
}

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 TableIndustryFilterInput {
    id: TableIDFilterInput
    name: TableStringFilterInput
}

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 TableSubscriberFilterInput {
    id: TableIDFilterInput
    name: TableStringFilterInput
    email: TableStringFilterInput
    phone: TableStringFilterInput
    streetAddress: TableStringFilterInput
}

input TableSubscriberQueriesFilterInput {
    id: TableIDFilterInput
    queries: TableIntFilterInput
}

input UpdateBadCustomerInput {
    id: ID!
    name: String
    phone: AWSPhone
    email: AWSEmail
    streetAddress: String
    dob: AWSDate
    passportNumber: String
    driversLicenceNumber: String
    ipAddress: AWSIPAddress
}

input UpdateDamageInput {
    id: ID!
    damage: Float
    comment: String
}

input UpdateIndustryInput {
    id: ID!
    name: String
}

input UpdateSubscriberInput {
    id: ID!
    name: String
    email: AWSEmail
    phone: AWSPhone
    streetAddress: String
    subscriberIndustryId: ID
}

input UpdateSubscriberQueriesInput {
    id: ID!
    queries: Int
    subscriberId: ID
}

schema {
    query: Query
    mutation: Mutation
    subscription: Subscription
}

我想添加一个功能,使订户可以查看所有其他订户或某些选定订户的损失详细信息。另外,我想限制订户可以看到其他订户的哪些数据,即,订户将设置其数据共享选项,就像他想共享damage commentdamage customer并在{{ 1}},他想共享damage customer中的nameaddress

在使用此功能时,我需要帮助。我正在将BadCustomer用于graphql

0 个答案:

没有答案