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

Type reflections #473

Merged
merged 6 commits into from
Jan 5, 2017
Merged

Type reflections #473

merged 6 commits into from
Jan 5, 2017

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Jan 3, 2017

When metaprogramming a GraphQL schema, it comes in handy to check for special types: introspection types, built-in scalars and built-in relay types.

Now, BaseType responds to checks for those things.

Additionally, built-in directives are flagged as such. (There's not really a way to add directives from user-space yet, but ... someday 😎 .)

Copy link
Contributor

@brndnblck brndnblck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this. 👍

@@ -8,10 +8,12 @@ module GraphQL
#
class Directive
include GraphQL::Define::InstanceDefinable
accepts_definitions :locations, :name, :description, :arguments, argument: GraphQL::Define::AssignArgument
accepts_definitions :locations, :name, :description, :arguments, :default, argument: GraphQL::Define::AssignArgument
Copy link
Contributor

@brndnblck brndnblck Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of readability, what do you think about calling this default_directive?

It has better symmetry with the rest of these changes here and seeing things like default = false in isolation feels a bit confusing.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that's much more consistent!

GraphQL::FLOAT_TYPE,
GraphQL::ID_TYPE,
]

# By default, these are included in a schema printout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge ❤️ for making this change in the printer as well.

@@ -24,6 +34,24 @@ def initialize_copy(other)
# @return [String, nil] a description for this type
attr_accessor :description

# @return [Boolean] Is this type a predefined introspection type?
def introspection?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to change this

if type.name.start_with?('__') && INTROSPECTION_TYPES[type.name] != type
now that we have introspection?.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💰 i'll give it a try

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 donezo

@rmosolgo rmosolgo merged commit 47d9d39 into master Jan 5, 2017
@rmosolgo rmosolgo deleted the type-reflections branch January 5, 2017 01:12
@rmosolgo
Copy link
Owner Author

rmosolgo commented Jan 5, 2017

Thanks for taking a look at this!

@rmosolgo rmosolgo modified the milestone: 1.4.0 Jan 8, 2017
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

Successfully merging this pull request may close these issues.

3 participants