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

entity-based @defer preview.0 #212

Merged
merged 27 commits into from
Sep 3, 2022
Merged

entity-based @defer preview.0 #212

merged 27 commits into from
Sep 3, 2022

Conversation

prasek
Copy link
Contributor

@prasek prasek commented Jul 18, 2022

How to get started with entity-based @defer preview

Run the all-in-one-demo

  1. Pull from this PR entity-based @defer preview.0 #212
make docker-up-local-router-defer-ac
  1. open the defer Apollo Client React demo app at http://localhost:3000/

  2. shutdown

make docker-down

Run only the Router and subgraphs - without the AC demo client

make docker-up-local-router
make smoke
  1. open Sandbox at http://localhost:4000/

  2. make additional queries like this

fragment MyFragment on Product {
    variation { name }
  }
}
query Dimensions {
  allProducts {
    ...MyFragment @defer
    sku
    id
  }
}
  1. write client apps that connect to localhost:4000

Signed-off-by: Phil Prasek prasek@gmail.com

@prasek prasek force-pushed the defer branch 2 times, most recently from e68acfe to 2df5e1f Compare July 21, 2022 05:55
@prasek prasek changed the title defer build defer alpha Jul 21, 2022
@prasek prasek force-pushed the defer branch 7 times, most recently from 66ee3a4 to 17a315d Compare July 21, 2022 15:56
@jpvajda
Copy link
Contributor

jpvajda commented Jul 22, 2022

@prasek it looks like some tests are failing on this PR

==============================================================
TEST 1: allProducts with delivery
==============================================================
curl -X POST -H Content-Type: application/json -H apollographql-client-name: smoke-test --data { "query": "query allProdDelivery { allProducts { delivery { estimatedDelivery, fastestDelivery }, createdBy { name, email } } }", "operationName": "allProdDelivery" } http://localhost:4000/
-------------------------
❌ TEST 1 Failed! 
-------------------------
[Expected: equals]
{"data":{"allProducts":[{"delivery":{"estimatedDelivery":"6/25/2021","fastestDelivery":"6/24/2021"},"createdBy":{"name":"Apollo Studio Support","email":"support@apollographql.com"}},{"delivery":{"estimatedDelivery":"6/25/2021","fastestDelivery":"6/24/2021"},"createdBy":{"name":"Apollo Studio Support","email":"support@apollographql.com"}}]}}
-------------------------
[Actual]
{"errors":[{"message":"value retrieval failed: spec error: invalid type error, expected another type than 'Named type Query_'","locations":[],"path":null}]}
-------------------------
❌ TEST 1 Failed! 
-------------------------
make: *** [smoke] Error 1

also when running locally in studio it looks like DeliveryEstimates and allProducts aren't available in the schema

Screen Shot 2022-07-22 at 12 58 31 PM

@jpvajda
Copy link
Contributor

jpvajda commented Jul 22, 2022

Actually I figured out what was wrong with that query, so that's not a issue anymore.

@@ -3,6 +3,7 @@ server:
cors:
origins:
- https://studio.apollographql.com
experimental_defer_support: true
Copy link
Contributor

@jpvajda jpvajda Jul 26, 2022

Choose a reason for hiding this comment

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

just adding a comment for reference, to test this with a local instance of a apollo graphql studio / explorer you need to add this as you'll get cors issues on the client side.

    allow_any_origin: true # added to allow for local development testing

@o0Ignition0o
Copy link
Contributor

Experimental defer support has shipped in router 0.14.0 🎉

it s worth noting the CORS default behavior wrt headers has changed in 0.14.0, so you probably want to set allow_any_header to true if you have allow_any_origin set to true

This configuration should get you started:

server:
  experimental_defer_support: true
  listen: 0.0.0.0:4000
  cors:
    allow_any_origin: true
    allow_any_header: true

BoD added a commit to BoD/DeferDemo that referenced this pull request Aug 22, 2022
BoD added a commit to BoD/DeferDemo that referenced this pull request Aug 23, 2022
BoD added a commit to BoD/DeferDemo that referenced this pull request Aug 23, 2022
@prasek prasek force-pushed the defer branch 3 times, most recently from 78feeb6 to 7825e63 Compare August 30, 2022 07:14
@prasek prasek changed the title defer alpha entity-based @defer preview Aug 30, 2022
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
Signed-off-by: Phil Prasek <prasek@gmail.com>
@prasek prasek changed the title entity-based @defer preview entity-based @defer preview.0 Sep 3, 2022
@prasek prasek enabled auto-merge (squash) September 3, 2022 21:49
@prasek prasek merged commit 91883c7 into apollographql:main Sep 3, 2022
@jpvajda
Copy link
Contributor

jpvajda commented Sep 6, 2022

@prasek now that this is merged in, is it best to demo from main and not PR 212?

@prasek
Copy link
Contributor Author

prasek commented Sep 6, 2022

@jpvajda yes PR 212 has been updated & merged to use router-1.0.0-alpha.1

  • @defer is now enabled by default, no router.yaml config needed

to demo you can use https://github.com/apollographql/supergraph-demo-fed2 main as a starting point:

  • make docker-up-local-router - uses the latest Router release
    • make smoke - see deferred queries
    • .scripts/smoke-defer-compressed.sh - the last 2 queries demonstrate an issue __typename in a fragment resulting in a non-incremental result being delivered which throws off some clients - a Router fix will be in the next alpha drop
    • manually startup client/defer-ac using npm run start

If you want to use Router main:

  • make run-router-main
    • then smoke tests above

@jpvajda
Copy link
Contributor

jpvajda commented Sep 6, 2022

@prasek I'm getting the follow errors on main

JVs-Apollo-Macbook:supergraph-demo-fed2 jvajda$ make docker-up-local-router
docker-compose -f docker-compose.router.yml up -d
Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 670, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1255, in request
  File "http/client.py", line 1301, in _send_request
  File "http/client.py", line 1250, in endheaders
  File "http/client.py", line 1010, in _send_output
  File "http/client.py", line 950, in send
  File "docker/transport/unixconn.py", line 43, in connect
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "requests/adapters.py", line 439, in send
  File "urllib3/connectionpool.py", line 726, in urlopen
  File "urllib3/util/retry.py", line 410, in increment
  File "urllib3/packages/six.py", line 734, in reraise
  File "urllib3/connectionpool.py", line 670, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1255, in request
  File "http/client.py", line 1301, in _send_request
  File "http/client.py", line 1250, in endheaders
  File "http/client.py", line 1010, in _send_output
  File "http/client.py", line 950, in send
  File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 214, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/utils/decorators.py", line 46, in inner
  File "docker/api/client.py", line 237, in _get
  File "requests/sessions.py", line 543, in get
  File "requests/sessions.py", line 530, in request
  File "requests/sessions.py", line 643, in send
  File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 200, in perform_command
  File "compose/cli/command.py", line 60, in project_from_options
  File "compose/cli/command.py", line 152, in get_project
  File "compose/cli/docker_client.py", line 41, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 197, in __init__
  File "docker/api/client.py", line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
[3573] Failed to execute script docker-compose
make: *** [docker-up-local-router] Error 255

THEN

JVs-Apollo-Macbook:supergraph-demo-fed2 jvajda$ make smoke
curl -X POST http://localhost:4000/ -H Content-Type: application/json --data { "query": "query { __schema { directives { name }}}" }
ERROR: CURL ERROR 7: Failed to connect() to host or proxy.
make: *** [smoke] Error 1
JVs-Apollo-Macbook:supergraph-demo-fed2 jvajda$ 

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.

None yet

4 participants