Skip to content

IDL Types inheritance and casting into IDL #369

Closed
@SerafimArts

Description

@SerafimArts

I did not find answers to these questions in the spec: http://facebook.github.io/graphql/
In this I want to set some details.

The question concerns all types that allow the use of inheritance in the following cases:

  1. type Object implements Interface {...}
  2. type Object {...} extend Object {...}

Extending the number of arguments

# section-1
interface Interface {
    field: String
}

# section-2
type Object implements Interface {
    field(arg1: String): String
}

# section-3
extend type Object {
    field(arg2: String): String
}
  1. Is it possible to expand the number of arguments during the interface implementation (section-2)? Or should there be an error?
  2. Is it possible to expand the number of arguments during a type extension (section-3)? Or should there be an error?
    2.1) Extend complements field arguments? (The result looks like: field (arg1: String, arg2: String): String)
    2.2) Does the extension redefine the field arguments? (The result looks like: field (arg2: String): String)

It seems to me that the answers are the following (please correct):

  1. Yes
  2. Yes
    2.1) Yes
    2.2) No

Overriding of Container Types

The question concerns types NonNull and List.

# section-1
interface Interface {
    field(arg1: String): String
}

# section-2
type Object implements Interface {
    field(arg1: String!): String!
}

The table of allowed overrides ("container type-cast coercion") looks like this (correct, if I'm wrong):

Tags:

  • :ok: - Allowed
  • - Not allowed
  • ? - I do not know
Definition Implementation Is acceptable?
Type Type! 🆗
Type [Type]
Type [Type!]
Type [Type]!
Type [Type!]!
------------ ---------------- ----------------
Type! Type
Type! [Type]
Type! [Type!]
Type! [Type]!
Type! [Type!]!
------------ ---------------- ----------------
[Type] Type
[Type] Type!
[Type] [Type!] 🆗
[Type] [Type]! 🆗
[Type] [Type!]! 🆗
------------ ---------------- ----------------
[Type!] Type
[Type!] Type!
[Type!] [Type]
[Type!] [Type]!
[Type!] [Type!]! 🆗
------------ ---------------- ----------------
[Type]! Type
[Type]! Type!
[Type]! [Type]
[Type]! [Type!]
[Type]! [Type!]! 🆗
------------ ---------------- ----------------
[Type!]! Type
[Type!]! Type!
[Type!]! [Type]
[Type!]! [Type!]
[Type!]! [Type]!

Overriding of Scalar Types

The question concerns the rules for converting scalar types during inheritance.

Example code:

# section-1
interface Interface {
    field: Int
}

# section-2
type Object implements Interface {
    field: Float
}
  1. Are these type conversions permissible?
  2. The table of allowed overrides ("scalar type-cast coercion") I can't imagine how it should look like :D

@leebyron I will be glad to receive help in answering these questions. Excuse me if I missed some nuances from the specification document =)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions