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

Upgrade elixir deps #118

Merged
merged 1 commit into from
Jun 28, 2022
Merged

Upgrade elixir deps #118

merged 1 commit into from
Jun 28, 2022

Conversation

kdawgwilk
Copy link
Contributor

This bumps some elixir dependencies and also fixes the docker build

@kdawgwilk
Copy link
Contributor Author

kdawgwilk commented Jun 27, 2022

Although we may want to wait until DivvyPayHQ/absinthe_federation#54 is released so we can have this point the the version that includes the fix and not to master

EDIT: This was released upstream and this PR was updated to use the new release

@dariuszkuc
Copy link
Member

Thanks for the fix!

It looks like though that _service test failed (SDL returned by the query { _service { sdl } } does not contain type Query)

@kdawgwilk
Copy link
Contributor Author

Looks like its actually the second assertion that is failing so this one instead

const basicallyTheSame = compareSchemas(productsPing.data?._service?.sdl);

Test failure from github action log

introspection
    expect(received).toBe(expected) // Object.is equality
    Expected: true
    Received: false
      15 |   const basicallyTheSame = compareSchemas(productsPing.data?._service?.sdl);
      16 |
    > 17 |   expect(basicallyTheSame).toBe(true);
         |                            ^
      18 | });
      19 |
      at Object.<anonymous> (src/tests/introspection.test.ts:17:28)

Any ideas on how to narrow down how they are different?

@dariuszkuc
Copy link
Member

Indeed. Sadly the unit test is pretty crude... It checks whether the expected objects are there but doesn't tell us what is missing.

Can you check what is the output of the _service { sdl } query and compare that against the expected schema?

@kdawgwilk
Copy link
Contributor Author

kdawgwilk commented Jun 27, 2022

Looks like its because the absinthe_federation library doesn't currently strip off _resolveReference fields when it renders the SDL. This has been a complicated topic for us to address in the elixir library because of how absinthe eagerly strips off types that are not referenced/accessible in the schema.

@kdawgwilk
Copy link
Contributor Author

This is the rendered SDL

"Represents a schema"
schema {
  query: Query
}

"""
type ProductVariation {
  id: ID!
}
"""
type ProductVariation {
  id: ID!
}

type _Service {
  sdl: String
}

"a union of all types that use the @key directive"
union _Entity = User | Product

"""
extend type Query {
  product(id: ID!): Product
}
"""
type Query @extends {
  """
  The _service field on the query root returns SDL
  which includes all of the service's types (after any non-federation transforms),
  as well as federation directive annotations on the fields and types.
  The federation schema modifications (i.e. new types and directive definitions)
  should not be included in this SDL.
  """
  _service: _Service!

  """
  Returns a non-nullable list of _Entity types
  and have a single argument with an argument name of representations
  and type [_Any!]! (non-nullable list of non-nullable _Any scalars).
  The _entities field on the query root must allow a list of _Any scalars
  which are "representations" of entities from external services.
  These representations should be validated with the following rules:

  - Any representation without a __typename: String field is invalid.
  - Representations must contain at least the fields defined in the fieldset of a @key directive on the base type.
  """
  _entities(representations: [_Any!]!): [_Entity]!

  product(id: ID!): Product
}

"The _Any scalar is used to pass representations of entities from external services into the root _entities field for execution."
scalar _Any

"""
type Product @key(fields: "id") @key(fields: "sku package") @key(fields: "sku variation { id }") {
  id: ID!
  sku: String
  package: String
  variation: ProductVariation
  dimensions: ProductDimension
  createdBy: User @provides(fields: "totalProductsCreated")
}
"""
type Product @key(fields: "sku variation { id }") @key(fields: "sku package") @key(fields: "id") {
  id: ID!
  sku: String
  package: String
  variation: ProductVariation
  dimensions: ProductDimension
  createdBy: User @provides(fields: "totalProductsCreated")
  _resolveReference: Product
}

"""
type ProductDimension {
  size: String
  weight: Float
}
"""
type ProductDimension {
  size: String
  weight: Float
}

"""
extend type User @key(fields: "email") {
  email: ID! @external
  totalProductsCreated: Int @external
}
"""
type User @extends @key(fields: "email") {
  email: ID! @external
  totalProductsCreated: Int @external
  _resolveReference: User
}

@kdawgwilk
Copy link
Contributor Author

Fix for rendering these fields is here DivvyPayHQ/absinthe_federation#55

@kdawgwilk
Copy link
Contributor Author

Alright this now includes that fix and here are the test results now

LibraryFederation 1 SupportFederation 2 Support
Absinthe.Federation
_service
`@key` (single)
`@key` (multi)
`@key` (composite)
`@requires`
`@provides`
`@ftv1`
`@link`
`@shareable`
`@tag`
`@override`
`@inaccessible`

Copy link
Member

@dariuszkuc dariuszkuc left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!

@dariuszkuc dariuszkuc merged commit 17eb1bb into apollographql:main Jun 28, 2022
@kdawgwilk kdawgwilk deleted the fix_elixir branch June 28, 2022 15:49
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.

2 participants