Commit graph

240 commits

Author SHA1 Message Date
Christian Legnitto
2502c1b6da Set up some release automation.
Partially fixes https://github.com/graphql-rust/juniper/issues/248.

* Install `cargo-release`. (currently need a patched one with https://github.com/sunng87/cargo-release/pull/74)
* Run `cargo make release-dry-run` to do a dry run of a release
* Run `cargo make release` to do a minor versioned release of every crate
* Run `cargo make release-patch` to do a patch release of every crate

To only release one crate:
* Change directories into the desired crate
* Point `cargo-make` to the workspace-level Makefile when running a command. For example, `cargo make --makefile ../Makefile.toml release-dry-run`.

From the workspace root, run `cargo
2018-12-17 13:45:56 -08:00
Christian Legnitto
73175d7a10 Bump version 2018-12-17 13:11:21 -08:00
Kevin Stenerson
0f2a654471 Infer graphql "deprecation" from #[deprecated(note = "...")] in derive (and macros) (#269)
* Update object/iface macro with doc/deprecated attrs for fields

* Use the note from `#[deprecated]` by default in derived GraphQLType

* Update to support multiline raw-docstring format

* Support bare deprecated attribute

* Update arguments to support #[doc] for parity with previous ` as ` syntax
2018-10-27 21:28:48 -06:00
Georg Semmler
2e5df9f8a4 Introduce an abstraction for scalar values (#251)
Introduce an abstraction for scalar values

Before this change,  possible scalar values were hard coded to be representable
by one of the following types: `i32`, `f64`, `String` or `bool`. This
restricts the types of custom scalar values that can be defined. For
example, it was not possible to define a scalar value that represents an
`i64` without mapping it to a string (which would be inefficient).

One solution to fix the example above would simply be to change the
internal representation to allow it to represent an `i64`, but this would
only fix the problem for one type (until someone wants to support
`i128` for example). Also this would make juniper not follow the
GraphQL standard closely.

This commit takes another approach, by making the exact "internal"
representation of scalar values swappable (in such a way that a downstream crate could provide its own representation tailored to their needs). This allows juniper to provide a default type that only
contains the types described in the standard whereas other crates could define custom scalars for their needs.

To accomplish this we need to change several things in the current implementation:

* Add some traits that abstract the behavior of such a scalar value representation
* Change `Value` and `InputValue` to have a scalar variant (with a
  generic type) instead of hard coded variants for the standard
  types. This implies adding a generic parameter to both enums that
  needs to be added in the whole crate.
* Change the parser to allow deciding between different types of
  scalar values. The problem is basically that the original parser
  implementation had no way to know whether a parsed integer number is
  a `i32` or a `i64` (for example). To fix this we added some knowledge
  of the existing schema to the parser.
* Fix some macros and derives to follow the new behavior.

This commit also contains an unrelated change about the way `juniper_codegen`
resolves items from `juniper`. The `_internal` flag is removed and
the resolution is replaced by a macro.

The scalar parsing strategy is as follows:

* Pass optional type information all the way down in the parser. If a
  field/type/… does note exist, just do not pass down the type
  information.
* The lexer now distinguishes between several fundamental scalar types (`String`, `Float`, `Int`). It does not try to actually parse those values, instead it just annotates them that this is a floating point number, an integer number, or a string value, etc.
* If type information exists while parsing a scalar value, try the following:
    1. Try parsing the value using that type information.
    2. If that fails try parsing the value using the inferred type information from the lexer.
* If no type information exists, try parsing the scalar value using the inferred type from the lexer,

All macros support the introduced scalar value abstraction. It is now possible to specify if a certain implementation should be based on a specific scalar value representation or be generic about the exact representation. All macros now default to the `DefaultScalarValue` type provided by
`juniper` if no scalar value representation is specified. This is done with usability and backwards compatibility in mind.

Finally, we allow specifying the scalar value representations via an attribute
(`#[graphql(scalar = "Type")]`). A default generic implementation
is provided.
2018-10-22 21:40:14 -06:00
Christian Legnitto
bd455c9130
Remove Appveyor (#264)
Now that we have azure pipelines set up, there is no need
to use appveyor.

Part of https://github.com/graphql-rust/juniper/issues/259
2018-10-08 21:15:09 -07:00
Christian Legnitto
9c1ce1fb7a
0.10.0 release (#236)
* Bump` juniper`, `juniper_codegen`, and `juniper_tests` versions.

* Bump integration crate requirements to include 0.10.0. `juniper_iron` gets a semver breaking version as it has a breaking change but `juniper_iron` does not.

* Move `juniper_rocket` changelog into one file. This aligns with `juniper_iron` and will be easier
to automate in the future.

* Let `juniper_warp` and `juniper_hyper` use `0.9.x` versions of Juniper. They don't rely on anything in 0.10.0 so don't require it.
2018-09-13 09:13:31 -07:00
Christian Legnitto
08c31357af
Add support for lifetime annotations when using derives (#226)
Fixes https://github.com/graphql-rust/juniper/issues/225
2018-08-27 15:25:15 -07:00
Christian Legnitto
22c955599a
Add support for skipping fields in GraphQL objects (#224)
Fields can now be skipped with the `#[graphql(skip)]` annotation. Note this
doesn't really make sense for GraphQLInputObjects so this isn't supported there.

Fixes https://github.com/graphql-rust/juniper/issues/220.
2018-08-27 15:09:42 -07:00
Dirkjan Ochtman
62d015cf86 Upgrade juniper_codegen dependencies (#231)
* Upgrade `juniper_codegen` to `syn-0.14`/`quote-0.6`

* Upgrade `juniper_codegen` to `regex-1.0`

* Fix comment typos in enum derive code

* Stop testing rust-1.21.0, replace with rust-1.23.0. rust-1.21.0 breaks with the newer dependencies
2018-08-27 14:51:12 -07:00
Christoph Herzog
56f71e934b Format code 2018-07-19 16:18:49 +02:00
Christian Legnitto
4be687f73e Add more unit tests for doc comments as descriptions 2018-06-20 20:45:34 +02:00
Christian Legnitto
1fd5c10327 Add support for using doc comments as descriptions
Fixes https://github.com/graphql-rust/juniper/issues/194.
2018-06-20 20:45:34 +02:00
Christian Legnitto
f0cbc97dc7
Do not assign field to itself if no description specified when deriving input object (#187)
If a field has a description, we properly generate a meta field definition like:

```rust
{
  let field = registry.field::<String>("id", &());
  let field = field.description("Whatever");
  field
}
```

If a field does not have a description, we were generating something like:

```rust
{
  let field = registry.field::<String>("id", &());
  let field = field; // <--- Note not needed
  field
}
```

This of course works (and was likely optimized out by the compiler), but bloats
generated code for no benefit.

This change merely makes the second case generate:

```rust
{
  let field = registry.field::<String>("id", &());

  field
}
```

Fixes https://github.com/graphql-rust/juniper/issues/185.
2018-06-06 18:40:45 -07:00
Christian Legnitto
7933bf92a5
Rename variable to be more descriptive. 2018-05-23 00:49:23 -07:00
piperRyan
9080448da2 Add Compile Time Check For "Invalid" Names (#170) 2018-05-23 00:25:20 -07:00
Christoph Herzog
05c1011d83 (juniper_codegen) Upgrade syn + quote 2018-05-03 01:49:36 +02:00
Ivan Dubrov
bfe2ef511a Provide type info to the concrete_type_name 2018-01-20 10:53:18 +01:00
Christoph Herzog
d00e74bb4e Format entire codebase with rustfmt 2018-01-13 12:25:55 +01:00
Christoph Herzog
40c946c81c 0.9.2 release
* Changelogs
* Update versions and dependency versions
2018-01-13 10:34:30 +01:00
theduke
ca9d5c1c1a Bump to 0.9.1 and fix up Cargo.toml files 2017-12-03 18:48:38 +01:00
theduke
643875838d (codegen) improve derive for InputObject
* Implement hack to allow usage in juniper crate
* implement (default) attribute for Default::default()
* Improve tests
2017-12-02 15:43:41 +01:00
theduke
6ff3f1fba4 (codegen) Improve enum field name generation
Introduce a to_upper_snake_case() helper to properly convert enum names
to GraphQL compatible names.

Previously, "SomeEnum" would be converted to "SOMEENUM" and not
"SOME_ENUM".
2017-12-02 15:43:41 +01:00
theduke
f858f416b8 Remove graphql_enum! macro in favor of custom derive
* Extend derive for enums to allow deriving inside the juniper crate
  itself. Note: this is a rather ugly hack right now, FIXME is in the
  code
* Remove the graphql_enum! macro and replace all internal use with
  derive
* Refactor introspection tests to use derive
2017-12-02 15:43:22 +01:00
theduke
7b066ef1f9 (docs) Add short crate docs to codegen. 2017-12-02 02:35:08 +01:00
theduke
3750349e71 Bump version to 0.9.0 2017-12-02 02:31:56 +01:00
theduke
141292ad91 Export codegen from main juniper crate
Use a trick for re-exporting proc-macros to supply juniper_derive as a
dependency of juniper.

Users will now just have to depend on juniper directly.
2017-12-02 02:27:41 +01:00
theduke
0372de84d5 Rename ToInputValue::to to to_input_value() 2017-08-29 05:34:35 +02:00
theduke
164aa29fdc Rename FromInputValue::from() to from_input_value() 2017-08-29 05:34:35 +02:00
Sam Rijs
a0f2c3bbdd Implement support for dynamic schemas 2017-08-07 22:15:09 +02:00
theduke
a826b22ffb Update Readme and Cargo files for new repo url 2017-08-07 08:20:05 +02:00
theduke
0c7e39f14e Rust fmt the whole codebase 2017-08-06 21:15:08 +02:00
theduke
81ce7780fa Codegen: implement description for custom derives + improve tests
Description attribute was available, but not actually used for derive
Object, InputObject and enum and the fields on input object.

Description is now properly set in each of those cases.

Also, tests for all three derives now properly verify the meta
information (name and description) for the derived GraphQLType.
2017-08-06 19:30:26 +02:00
theduke
6c45fba9bd Fix some warnings in codegen + tests. 2017-08-06 19:30:26 +02:00
theduke
6c7dc0493d Rename custom derive modules for consistency.
codegen/enums -> codegen/derive_enum
codegen/input_objects -> codegen/derive_input_object
tests/enums -> tests/derive_enum
tests/input_objects -> tests/derive_input_object
2017-08-06 19:30:26 +02:00
theduke
e835a5e019 Codegen: Add custom derive for GraphQLObject
This adds a simple derive for objects that implements GraphQLType for
structs which do not require any manual resolvers.

This could be extended in the future to provide a custom resolver
function via an attribute.

Also adds an integration test.
2017-08-06 19:30:26 +02:00
theduke
c27d2c7a23 Make variant name for derived enums upper case by default 2017-07-12 21:51:24 +02:00
theduke
1312c6a026 Implement derive for input objects 2017-07-12 21:51:24 +02:00
theduke
e42228e2d5 Duplicating to_camel_case in codegen 2017-07-12 21:51:24 +02:00
theduke
2bcfc315ad Use more descriptive variant variable names for enum deriving 2017-07-12 21:51:24 +02:00
theduke
d33db983de Add juniper_codegen crate.
This crate will contain multiple custom_derive implementations.

For now, only enum is supported.
2017-07-12 21:51:24 +02:00