Skip to content

Validation error using '@include' directive if schema comes from introspection #278

Closed
@SuperBo

Description

@SuperBo

When I try to use "@include" directive in my string query, I got this error:
graphql.error.graphql_error.GraphQLError: Unknown directive '@include'.

I think "@include" and "@Skip" are in standards of GraphQL https://graphql.org/learn/queries/#directives

Version in my environment

gql[requests]==3.0.0b1
graphql-core==3.1.6; python_version >= '3.6' and python_version < '4'

GraphQL Query

query fetchPool($with_swap: Boolean!) {
  pool(id: "0x83abecf7204d5afc1bea5df734f085f2535a9976") {
    id
    createdAtTimestamp
    swaps (first: 2) @include(if: $with_swap ) {
      id
      timestamp
    }
  }
}

Full stack trace:

Traceback (most recent call last):
File "test.py", line 27, in
result = client.execute(q, variable_values= {'with_swap': True})
File "/Users/ynguyen/.local/share/virtualenvs/activelp_v1_prod-cEysbnrO/lib/python3.8/site-packages/gql/client.py", line 186, in execute
return self.execute_sync(document, *args, **kwargs)
File "/Users/ynguyen/.local/share/virtualenvs/activelp_v1_prod-cEysbnrO/lib/python3.8/site-packages/gql/client.py", line 134, in execute_sync
return session.execute(document, *args, **kwargs)
File "/Users/ynguyen/.local/share/virtualenvs/activelp_v1_prod-cEysbnrO/lib/python3.8/site-packages/gql/client.py", line 389, in execute
result = self._execute(
File "/Users/ynguyen/.local/share/virtualenvs/activelp_v1_prod-cEysbnrO/lib/python3.8/site-packages/gql/client.py", line 328, in _execute
self.client.validate(document)
File "/Users/ynguyen/.local/share/virtualenvs/activelp_v1_prod-cEysbnrO/lib/python3.8/site-packages/gql/client.py", line 129, in validate
raise validation_errors[0]
graphql.error.graphql_error.GraphQLError: Unknown directive '@include'.

GraphQL request:6:22
5 | createdAtTimestamp
6 | swaps (first: 2) @include(if: $with_swap ) {
| ^
7 | id

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions