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

Add GraphQL interface #49

Merged
merged 3 commits into from
Jul 14, 2020
Merged

Add GraphQL interface #49

merged 3 commits into from
Jul 14, 2020

Conversation

mvantellingen
Copy link
Member

@mvantellingen mvantellingen commented Jul 7, 2020

Note that this is a work in progress (missing unittest)

Example usage:

var respData struct {
	Product struct {
		ID      string `json:"id"`
		Version int    `json:"version"`
	} `json:"product"`
}

query := client.NewGraphQLQuery(`
	query ($sku: String!)  {
		product(sku: $sku) {
			id
			version
		}
	}
	`)
query.Bind("sku", "mysku")

err := query.Execute(&respData)
if err != nil {
	panic(err)
}
fmt.Println(respData.Product.ID)

See also https://github.com/labd/terraform-provider-commercetools/pull/109/files

@mvantellingen mvantellingen marked this pull request as draft July 7, 2020 14:05
Copy link
Member

@davidweterings davidweterings left a comment

Choose a reason for hiding this comment

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

Looks pretty clear to me 👍

@mvantellingen mvantellingen force-pushed the feature/graphql-interface branch from 01ff0c7 to 7c97af1 Compare July 7, 2020 14:26
@codecov
Copy link

codecov bot commented Jul 7, 2020

Codecov Report

Merging #49 into master will increase coverage by 0.05%.
The diff coverage is 26.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   10.57%   10.63%   +0.05%     
==========================================
  Files          61       62       +1     
  Lines       13160    13227      +67     
==========================================
+ Hits         1392     1407      +15     
- Misses      11612    11661      +49     
- Partials      156      159       +3     
Impacted Files Coverage Δ
commercetools/client_graphql.go 0.00% <0.00%> (ø)
commercetools/client.go 68.78% <63.33%> (-1.49%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c16178...fb8e54c. Read the comment docs.

@mvantellingen mvantellingen force-pushed the feature/graphql-interface branch 5 times, most recently from ef6c7eb to e68df95 Compare July 14, 2020 19:45
@mvantellingen mvantellingen marked this pull request as ready for review July 14, 2020 19:46
This PR refactors the existing client request/response processing into
two separate functions since we want to re-use the request logic but
handle the response for graphql differently.
@mvantellingen mvantellingen force-pushed the feature/graphql-interface branch from e68df95 to fb8e54c Compare July 14, 2020 19:52
@mvantellingen mvantellingen changed the title WIP: Feature/graphql interface Add GraphQL interface Jul 14, 2020
@mvantellingen
Copy link
Member Author

Need to add unittest later (want to get a poc working for custom apps first)

@mvantellingen mvantellingen merged commit 7ff1847 into master Jul 14, 2020
@mvantellingen mvantellingen deleted the feature/graphql-interface branch July 29, 2020 10:27
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.

2 participants