Skip to content

Should Schema.build_from_definition inherit fields from the interface? #1972

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

Closed
emilebosch opened this issue Nov 24, 2018 · 2 comments
Closed

Comments

@emilebosch
Copy link
Contributor

Should schema with build_from_definition implicitly copy the fields over from the interface to the type? I.e. that I don't have to explicitly copy the field name under the student? If this is required should it then not raise an error for an incomplete implementation?

An SDL example to clarify:

interface User {
  name: String!
}

type Student implements User {
  grade: Int! 
  # Implicit `Name: String!`  ?
}

type Query {
  student: Student
}

type Mutation {
  name: String
}

However I see that in https://graphql.org/learn/schema/#interfaces, they explicitly include the fields. Shouldn't there be a warning then at least with build_schema_from_definition, that the type doesn't adhere to the interface?

@emilebosch
Copy link
Contributor Author

Okay, I read up here that this degrades the readability of the schema. Which I agree with actually: graphql/graphql-spec#335 (comment)

See: #500 (comment)

TL;DR this proposal doesn't allow new use cases that were not already possible and degrades readability of schema in the name of writing less, which goes against GraphQL's guiding principles

However should the build_from_definition not BANG when I am not implementing that interface fully?

@rmosolgo
Copy link
Owner

Yeah, it makes sense to check for a resolver earlier on. I'm not working much on build_from_definition right now, but I'd welcome a PR for that!

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

No branches or pull requests

2 participants