gpt4 book ai didi

GraphQL 和 Prisma : why does one redefine types in the application schema when they are already part of the Prisma database schema?

转载 作者:行者123 更新时间:2023-12-02 23:59:40 24 4
gpt4 key购买 nike

嗨 - 我一直在关注 GraphQL/Prisma 教程 ( https://www.howtographql.com/graphql-js/6-authentication/ ),我想知道为什么要在应用程序模式中重新定义类型,因为它们已经是 Prisma 数据库模式的一部分并且可以从那里。

教程给出的答案是“从客户端应用程序隐藏潜在的敏感信息”。这究竟意味着什么?为什么我们要复制“schema.graphql”和“datamodel.prisma”中的定义?因为定义略有不同(即“数据模型”包含像 @unique 这样的标签)?我们如何向客户端应用程序隐藏内容?我仍然很困惑......

特别是在“schema.graphql”中我有

type User {
id: ID!
name: String!
email: String!
links: [Link!]!
}

在“datamodel.prisma”中我有

type User {
id: ID! @unique
name: String!
email: String! @unique
password: String!
links: [ Link!] !
}

最佳答案

架构没有密码字段,这可能就是“隐藏潜在敏感信息”的含义。

这在任何 API 中都是常见做法,不会从持久存储中返回所有数据。

关于GraphQL 和 Prisma : why does one redefine types in the application schema when they are already part of the Prisma database schema?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55045414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com