sgqlc.introspection module¶
Introspection¶
Provides the standard GraphQL Introspection Query, same as https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js however allows to choose whether to include descriptions and deprecated fields.
Downloading schema.json¶
Usually services provide a schema.json
file with the introspection results
or offer a development server where the introspection query can be executed
and saved as JSON:
python3 \
-m sgqlc.introspection \
--exclude-deprecated \
-H "Authorization: bearer ${TOKEN}" \
https://server.com/graphql \
schema.json
If the descriptions are not needed, then they can be excluded (saves bandwith and space):
python3 \
-m sgqlc.introspection \
--exclude-deprecated \
--exclude-description \
-H "Authorization: bearer ${TOKEN}" \
https://server.com/graphql \
schema.json
- license:
ISC
- sgqlc.introspection.variables(include_description=True, include_deprecated=True)[source]¶
Return variables to be used with
IntrospectionQuery
GraphQL operation.- Parameters:
- Returns:
dict with GraphQL variables.
- Return type:
sgqlc.introspection Command Line Options¶
Introspect a GraphQL endpoint using HTTP
usage: python3 -m sgqlc.introspection [-h] [--exclude-deprecated]
[--exclude-description]
[--header HEADER] [--timeout TIMEOUT]
[--verbose]
url [outfile]
Positional Arguments¶
- url
GraphQL endpoint address.
- outfile
Where to write json. Default=stdout
Default: <_io.TextIOWrapper name=’<stdout>’ mode=’w’ encoding=’utf-8’>
Named Arguments¶
- --exclude-deprecated
If given, will exclude deprecated fields and enumeration values.
Default: False
- --exclude-description
If given, will exclude description (documentation).
Default: False
- --header, -H
NAME=VALUE HTTP header to send. Example: “Authorization: bearer ${token}”
Default: []
- --timeout, -t
Request timeout, in seconds.
- --verbose, -v
Increase verbosity
Default: 0