Skip to main content

Create a WSGI Application for a GraphQL schema.

Usage

Use the GraphQLApplication from wsgi_graphql.

from wsgi_graphql import GraphQLApplication
application = GraphQLApplication(schema)

Options

  • schema: GraphQLSchema to serve with this application.

  • execute_options: Dictionary of options to be passed to graphql.execute via graphql_server.run_http_query. If the dictionary values are callable they will be called (see example below).

  • format_error: Function to format errors (defaults to graphql_server.default_format_error).

  • encode: Function to encode dictionary (defaults to graphql_server.json_encode).

All execute_options can be callable (i.e. functions) and will receive the current environ as an argument. This can be used for tasks like parsing authentication tokens and inserting results as context_value.

This snippet from the example.py sets the context_value to a dictionary containing the value of the request header greet.

application = GraphQLApplication(schema, execute_options={
    'context_value': lambda environ: {
        'greet': environ.get('HTTP_GREET')
    }
})

This curl command will return {"data":{"hello":"world"}}.

curl --request POST\
 --url http://localhost:8080\
 --header 'Content-Type: application/graphql'\
 --header 'greet: world'\
 --data 'query {hello}'

Metadata

Release files for wsgi_graphql 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wsgi_graphql 0.0.2
File Size Uploaded
wsgi_graphql-0.0.2.tar.gz 3.5 kB Details

Release files / wsgi_graphql-0.0.2.tar.gz

Download URL wsgi_graphql-0.0.2.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
20412c281b59d4add43464f858d62ede99d5fa016aab2acf7aced6534dc9a028
BLAKE2b-256 checksum
How to use checksums
9c6b1c855d459e428f811203375e56b97d5267676f3846cb509fc1420d2a2417
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page