Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build permissions system on the backend #3

Open
Weakky opened this issue May 16, 2018 · 1 comment
Open

Build permissions system on the backend #3

Weakky opened this issue May 16, 2018 · 1 comment
Labels

Comments

@Weakky
Copy link
Owner

Weakky commented May 16, 2018

Using graphql-shield or https://blog.graph.cool/graphql-directive-permissions-authorization-made-easy-54c076b5368e

Step1. Allow only users with role ADMIN to perform those mutations:

# Upsert mutations
  upsertBrand(brandId: ID, categoryId: ID!, name: String!): Brand
  upsertAttribute(attributeId: ID, categoryId: ID!, value: String!): Attribute
  upsertCategory(categoryId: ID, name: String!): Category
  upsertOption(optionId: ID, name: String!, values: [OptionValueInput!]!, categoryId: ID!): Option
  upsertProduct(
    productId: ID,
    name: String!,
    categoryId: ID!,
    brandId: ID!,
    available: Boolean!,
    optionIds: [ID!]!,
    variants: [ProductVariantInput!]!,
    attributesIds: [ID!]!,
    unavailableOptionsValuesIds: [ID!]!,
    displayPrice: Float!,
    imageUrl: String
  ): Product

  #Upsert Shop metadata
  upsertBestSalesProducts(shopMetadataId: ID, bestSalesProducts: [OrderableProductInput!]!): ShopMetadata!
  upsertNewProducts(shopMetadataId: ID, newProducts: [OrderableProductInput!]!): ShopMetadata!
  upsertMOTD(shopMetadataId: ID, MOTD: String!): ShopMetadata!

  # Delete mutations
  deleteProduct(productId: ID!): Product
  deleteOption(optionId: ID!): Option
  deleteBrand(brandId: ID!): Brand
  deleteAttribute(attributeId: ID!): Attribute
  deleteCategory(categoryId: ID!): Category

#Order mutations
  setOrderAsPrepared(orderId: ID!): Order #Can be updated only by admins (eg: to set order as prepared)

And those queries:

allCustomers: [User!]!
@Weakky Weakky added the Prisma label May 16, 2018
@agustif
Copy link

agustif commented Sep 30, 2018

+1 to graphql-shield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants