question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional federated type

See original GitHub issue

When I want to return a type that has required fields or None unexpected error is thrown

Here https://github.com/mirumee/ariadne/blob/0.12.0/tests/federation/test_schema.py#L431-L469 you have a test that works correctly. However, when you’ll change type fields to the required test will fail with error:

[GraphQLError('Cannot return null for non-nullable field Product.name.', locations=[SourceLocation(line=6, column=25)], path=['_entities', 0, 'name'])]

Test to reproduce:

def test_federated_schema_execute_reference_resolver_that_returns_none():
    type_defs = """
        type Query {
            rootField: String
        }
        type Product @key(fields: "upc") {
            upc: Int!
            name: String!
        }
    """

    product = FederatedObjectType("Product")

    @product.reference_resolver()
    def product_reference_resolver(_obj, _info, reference):
        assert reference["upc"] == 1
        # return None

    schema = make_federated_schema(type_defs, product)

    result = graphql_sync(
        schema,
        """
            query GetEntities($representations: [_Any!]!) {
                _entities(representations: $representations) {
                    ... on Product {
                        __typename
                        name
                    }
                }
            }
        """,
        variable_values={"representations": [{"__typename": "Product", "upc": 1,},],},
    )

    assert result.errors is None
    assert result.data["_entities"][0]["__typename"] == "Product"
    assert result.data["_entities"][0]["name"] is None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rafalpcommented, Mar 17, 2021

@kamilglod it was released 4.5 hours ago, enjoy!

0reactions
kamilglodcommented, Mar 17, 2021

Indeed, master branch version works correctly! 😃 When you’re planning to release 0.13?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value types in Apollo Federation - Apollo GraphQL Docs
Types like this are called value types. This article describes how to share value types and their fields in federated graph, enabling multiple...
Read more >
tff.types.FederatedType | TensorFlow Federated
An instance of tff.Type or something convertible to it, that represents the type of the member components of each value of this federated...
Read more >
Chapter 11 Choosing a Federation Option - Oracle Help Center
To get started, SAML v2 is strongly preferred for federation. WS-Federation is an alternative for integrating with Active Directory Federation Services (ADFS).
Read more >
Process Template Query Entity List Resource - GET Method
Use this method to retrieve a list of process template entities via a query. Sample Method Invocation. GET /rest/bpm/federated/bfm/v1/processTemplates/query/{ ...
Read more >
Implementing Federated GraphQL Microservices using Apollo ...
In addition, we pass the subscriptions: false option to the apollo server ... In the Query type, the users and the user(id: ID!)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found