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

Updates to documentation and examples. #679

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions guides/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ object :item do
end
```

Now, you can use Absinthe to execute a query document. Keep in mind that for
Now you can use Absinthe to execute a query document. Keep in mind that for
HTTP, you'll probably want to use
[Absinthe.Plug](plug-phoenix.html) instead of executing
GraphQL query documents yourself. Absinthe doesn't know or care about HTTP,
but the `absinthe_plug` project does -- and handles the vagaries of interacting
but the `absinthe_plug` project does: it handles the vagaries of interacting
with HTTP GraphQL clients so you don't have to.

If you _were_ executing query documents yourself (lets assume for a local tool),
If you _were_ executing query documents yourself (let's assume for a local tool),
it would go something like this:

```elixir
Expand All @@ -82,6 +82,20 @@ it would go something like this:
{:ok, %{data: %{"item" => %{"name" => "Foo"}}}}
```

Your schemas can be further customized using the options available to
`Absinthe.Schema.Notation.field/4` to help provide for a richer experience for
your users, customize the field names, or mark fields as deprecated.

```elixir
# filename: myapp/language_schema.ex
@desc "A Language"
object :language do
field :id, :id
field :iso_639_1, :string, description: "2 character ISO 639-1 code", name: "iso639"
field :name, :string, description: "English name of the language"
end
```

## Importing Types

We could also move our type definitions out into a different module, for instance, `MyAppWeb.Schema.Types`, and then use `import_types` in our `MyAppWeb.Schema`:
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/type/field.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Absinthe.Type.Field do
The configuration for a field.

* `:name` - The name of the field, usually assigned automatically by
the `Absinthe.Schema.Notation.field/1`.
the `Absinthe.Schema.Notation.field/1`. Including this option will bypass the snake_case to camelCase conversion.
* `:description` - Description of a field, useful for introspection.
* `:deprecation` - Deprecation information for a field, usually
set-up using `Absinthe.Schema.Notation.deprecate/1`.
Expand Down Expand Up @@ -104,7 +104,7 @@ defmodule Absinthe.Type.Field do
### Custom Resolution

When accepting arguments, however, you probably need to use them for
something. Here's an example of definining a field that looks up a list of
something. Here's an example of defining a field that looks up a list of
users for a given `location_id`:
```
query do
Expand Down