Skip to content

Why each scalar MakeNullable? #261

Description

@sergeysova

I have a graphQL schema:

Details
# Directs the executor to query only when the field exists.
directive @ifdef on FIELD

type AccessToken {
  token: String!
  scopes: [String!]!
  expiresAt: DateTime!
  registrationId: UUID!
  registration: UserRegistration
}

type Application {
  id: UUID!
  isDev: Boolean!
  redirectUri: [String!]!
  title: String!
  allowedRegistrations: Boolean!
  registrations: [UserRegistration!]!
}

input ApplicationCreate {
  title: String!
  redirectUri: [String!]!
  isDev: Boolean
  allowedRegistrations: Boolean
}

type ApplicationSecret {
  id: UUID!
  isDev: Boolean!
  redirectUri: [String!]!
  title: String!
  allowedRegistrations: Boolean!

  # Allowed to read only after application is created
  secretKey: String!
}

# Implement the DateTime<Utc> scalar
#
# The input/output is a string in RFC3339 format.
scalar DateTime

type Mutation {
  applicationCreate(form: ApplicationCreate!): ApplicationSecret!
  applicationRegenerateSecret(applicationId: UUID!): ApplicationSecret
  registerRequestCreate(email: String!): RegisterRequest!
  registerRequestDeleteAllForEmail(email: String!): Int!
}

type Query {
  version: String!
  accessTokens: [AccessToken!]!
  application(id: UUID!): Application
  applications: [Application!]!
  registerRequests: [RegisterRequest!]!
  users: [User!]!
  userByEmail(email: String!): User
  userById(userId: UUID!): User
}

type RegisterRequest {
  email: String!
  code: String!
  expiresAt: DateTime!
}

# A UUID is a unique 128-bit number, stored as 16 octets. UUIDs are parsed as Strings
# within GraphQL. UUIDs are used to assign unique identifiers to entities without requiring a central
# allocating authority.
#
# # References
#
# * [Wikipedia: Universally Unique Identifier](http://en.wikipedia.org/wiki/Universally_unique_identifier)
# * [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace](http://tools.ietf.org/html/rfc4122)
scalar UUID

type User {
  id: UUID!
  email: String!
  canonicalEmail: String!
  firstName: String!
  lastName: String!
  registrations: [UserRegistration!]!
}

type UserRegistration {
  id: UUID!

  # Field renamed from `client_id`
  applicationId: UUID!
  createdAt: DateTime!
  userId: UUID!
  user: User
  application: Application
  accessTokens: [AccessToken!]!
}

As I see Application.title has a strong String! type.

But if I want to fetch it via resolved, I see string | undefined:

image

The same via useQuery():

image

Why there string | undefined on String! type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions