Skip to content

Commit

Permalink
Add more places where custom arguments and fields should be attached
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Mosolgo authored Oct 27, 2020
1 parent 2e35e5c commit c67f4b3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions guides/type_definitions/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ class Types::BaseObject < GraphQL::Schema::Object
field_class AuthorizedField
end

# And/Or
# And....
class Types::BaseInterface < GraphQL::Schema::Interface
field_class AuthorizedField
end

class Mutations::BaseMutation < GraphQL::Schema::RelayClassicMutation
field_class AuthorizedField
end
```

Now, `AuthorizedField.new(*args, &block)` will be used to create `GraphQL::Schema::Field`s on those types. At runtime `field.required_permission` will return the configured value.
Expand Down Expand Up @@ -152,7 +156,7 @@ Edges may be customized in a similar way to Connections.
Arguments may be customized in a similar way to Fields.

- Create a new class extending `GraphQL::Schema::Argument`
- Assign it to your field class with `argument_class(MyArgClass)`
- Use `argument_class(MyArgClass)` to assign it to your base field class, base resolver class, and base mutation class

Then, in your custom argument class, you can use `#initialize(name, type, desc = nil, **kwargs)` to take input from the DSL.

Expand Down

0 comments on commit c67f4b3

Please sign in to comment.