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

Quick Start Tutorial Needed #62

Open
ndanielsen opened this issue Sep 4, 2019 · 3 comments
Open

Quick Start Tutorial Needed #62

ndanielsen opened this issue Sep 4, 2019 · 3 comments
Assignees

Comments

@ndanielsen
Copy link

@ndanielsen ndanielsen commented Sep 4, 2019

Loving this project.

I feel like this project would benefit from a short quick start tutorial that demonstrate common methods such as:

Create item

    mutation = Operation(schema.Mutation)  # note 'schema.'
    mutation.create_item(input=dict(id="23432")).__fields__()

List items with filter

    op = Operation(schema.Query)  # note 'schema.'
    op.list_items(filter={"number_id": {'eq': 123456 }})

Making HTTP Calls to AWS AppSync (Managed Graphql Service)

  query = Operation(schema.Query)
  items = query.list_items()

  query = bytes(query).decode("utf-8")

  post_data = json.dumps({"query": query}).encode("utf-8")

  headers = {}
  headers["Accept"] = "application/json; charset=utf-8"

  auth = AWS4Auth(
        access_key_id,
        secret_access_key,
        region_name,
        "appsync",
        session_token=session_token,
    )

  response = requests.post(url, auth=auth, data=post_data, headers=headers)

I'll add more examples as I work them out =)

@ndanielsen
Copy link
Author

@ndanielsen ndanielsen commented Sep 4, 2019

Note, I'm on v7

@barbieri
Copy link
Member

@barbieri barbieri commented Sep 5, 2019

good. But why do you need to go with requests instead of using the existing HTTPEndpoint? If you need to have more details exposed, we could add as properties (we already have headers), but you can provide your own urlopen (compatible with urllib.request.urlopen()) or even extend that class.

If you have some time to write some RST, we can take that patch to publish it alongside code docs at https://sgqlc.readthedocs.io/en/latest/

@ndanielsen
Copy link
Author

@ndanielsen ndanielsen commented Sep 6, 2019

@barbieri Thanks for the response. I'll document some more elements of the tutorial and then put it in at that point.

As for using requests, I looked under the hood at HTTPEndpoint. My usecase is utilizing AWS signed urls to query the graphql api, and I'm trying to avoid reimplementing AWS4Auth to make it work with HTTPEndpoint.

So while HTTPEndpoint seems to work well for the most part, I'm familiar with the requests api and can adapt it into the app with minimal learning curve or adding additional functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.