这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@nizar-m
Copy link
Contributor

@nizar-m nizar-m commented Jan 10, 2019

Description

What component does this PR affect?

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System

Requires changes from other components? If yes, please mark the components:

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System

Related Issue

#1276

Solution and Design

  • Validate implementation of interfaces by object types
  • Validate union types
  • Support introspection query for union and interface

Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs update
  • Community content

Checklist:

  • I have read the contributing guide and my code conforms to the guidelines.
  • This change requires a change in the documentation.
  • I have updated the documentation accordingly.
  • I have added required tests.

@hasura-bot
Copy link
Contributor

Review app for commit fd9ea10 deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-fd9ea10

instance EquatableGType ObjTyInfo where
type EqProps ObjTyInfo =
(G.NamedType, Map.HashMap G.Name (G.Name, G.GType, ParamMap))
getEqProps a = (,) (_otiName a) (Map.map getEqProps (_otiFields a))
Copy link
Member

Choose a reason for hiding this comment

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

We'll also need to check if the interfaces that are implemented are same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed getEqProps to output a 3 part tuple, which includes HashSet of implementing interfaces

, _otiFields :: !ObjFieldMap
{ _otiDesc :: !(Maybe G.Description)
, _otiName :: !G.NamedType
, _otiImplIFaces :: [G.NamedType]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can use a hashset here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed from Array of implementing interfaces to HashSet.

2) In Object equality check, check whether the implementing interfaces are the same as well
@hasura-bot
Copy link
Contributor

Review app for commit e40372e deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-e40372e

@hasura-bot
Copy link
Contributor

Review app for commit d0ebdeb deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-d0ebdeb

@nizar-m nizar-m changed the title Support interface types in remote schema Support union and interface types in remote schema (close #1276) Jan 13, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 9970446 deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-9970446

@ecthiender ecthiender changed the title Support union and interface types in remote schema (close #1276) support union and interface types in remote schema (close #1276) Jan 15, 2019
@ecthiender
Copy link
Contributor

@nizar-m can you also mention which portions of documentation has to change?

@ecthiender ecthiender added the c/server Related to server label Jan 15, 2019
@ecthiender ecthiender added this to the v1.0.0-alpha35 milestone Jan 15, 2019
2) Test for remote schema validation errors with union types
@hasura-bot
Copy link
Contributor

Review app for commit 2de92c3 deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-2de92c3

@hasura-bot
Copy link
Contributor

Review app for commit 44b2c68 deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-44b2c68

…ct and Interface types

2) Tests for schema validation errors on object types implementing interfaces
@hasura-bot
Copy link
Contributor

Review app for commit 4485c0b deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-4485c0b

@0x777 0x777 removed this from the v1.0.0-alpha36 milestone Jan 28, 2019
@hasura-bot
Copy link
Contributor

Review app for commit d43a42f deployed to Heroku: https://hge-ci-pull-1361.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1361-d43a42f

@shahidhk shahidhk merged commit 32387ba into hasura:master Jan 28, 2019
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-1361.herokuapp.com is deleted

hasura-bot pushed a commit that referenced this pull request Nov 20, 2024
…ssues with nested fields (#1361)

### What
This PR reworks the GraphQL schema annotation types and IR parsing for
boolean expressions. This was required because the existing code was
quite tangled and broken as it did not properly handled nested fields.
For example, it had the following issues:

* If you use more than one nested field in a single where, an invalid
NDC query is generated with mangled field paths
* If you use logical operators inside a nested field, an internal error
occurs

The new annotation structure and IR parsing code cleanly matches the two
types of boolean expressions we currently have: object boolean
expressions and scalar boolean expressions. The new parsing code
correctly tracks nested fields and allows arbitrary nesting of object
boolean expressions (and therefore logical operators at the object
boolean expression level).

### How

In `crates/graphql/schema/src/types.rs` `BooleanExpressionAnnotation`
has been reworked to capture the two different types of boolean
expressions. It now has the two `ObjectBooleanExpressionField` and
`ScalarBooleanExpressionField` variants, which are used to denote fields
on each of the different types of boolean expression objects. Previously
scalar boolean expression annotations lived on `ModelInputAnnotation`,
muddying the waters.

Then in `crates/graphql/ir/src/filter.rs`, we have
`resolve_object_boolean_expression` and
`resolve_scalar_boolean_expression` which are capable of reading the
respective variants of boolean expressions.
`resolve_object_boolean_expression` is recursive, and so nested logical
operators are handled naturally. As nested fields are descended through,
this is kept track of with `column_path`.

Some new fields were added to the existing nested object test
(`crates/engine/tests/execute/models/select_many/where/nested_select/object/request.gql`)
to capture and test the previously broken scenarios.

A minor fix was made to `crates/graphql/frontend/src/to_opendd_ir.rs`
because it did not handle multiple root fields properly, as it did not
use the root field aliases and ended up overwriting the same query over
and over. This resulted in many snapshots getting updated, even though
they are unrelated to the real change in this PR.

V3_GIT_ORIGIN_REV_ID: f7cbbe8c86f542150e0ce247c6597df717836c06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/server Related to server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants