StoreFront api shopify in Flutter app ("Nodes" & "Edges" conflicting class names) - flutter

My need is very simple.
I want to query Shopify's Storefront api using Flutter, but there is a catch.
My response always have multiple nodes and edges. and each node/edge containing different objects.
Now the problem arise when i try to use JsonToDart generator in android studio and it creates each class with its own model. containing different fields and it conflicts with the other Node class.
screenshot is attached for reference.
i want to know how i can tackle this problem.
my graphQL query is:
{
products(first: 2) {
nodes {
id
title
createdAt
description
descriptionHtml
featuredImage {
id
url
width
height
altText
}
onlineStoreUrl
options {
id
name
values
}
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
productType
publishedAt
requiresSellingPlan
seo {
title
description
}
tags
totalInventory
updatedAt
vendor
images(first: 2) {
nodes {
id
url
width
height
altText
}
}
media(first: 2) {
nodes {
alt
mediaContentType
}
}
variants(first: 2) {
nodes {
availableForSale
barcode
id
image {
id
url
width
height
altText
}
requiresShipping
sku
title
weight
weightUnit
}
}
}
}
}

You shouldn't have multiple classes called the same way, this creates confusion in your code, and if for any reason you do, they have to be defined in different files and whenever you import them somewhere you have to pick the right file to import it from

Related

GitHub Projects Beta - How to get the data from a view in the API

My company is using the new GitHub projects beta and we're really enjoying the experience, but we're facing a problem and it is how to export the data from a specific view (or even all the data) with all the custom columns that we have.
The ideal solution for us is to get this same data as JSON using the API.
Using https://api.github.com/orgs/.../issues does not work because the issues does not have the custom columns that we create inside the project, and https://api.github.com/orgs/.../projects does not have the data of the issues.
Any idea or work-around to get this data easily using APIs?
After reading the feedback post on GitHub, it's not possible to do it with API, just GraphQL, at least for now.
So my problem was solved with this useful code.
To get the first 100 project from your organization and their ID:
query{
organization(login: "MY_ORG") {
projectsNext(first: 20) {
nodes {
id
title
}
}
}
}
To get the first 100 issues and drafts from a specific project:
{
node(id: "My_Project_ID") {
... on ProjectNext {
items(first: 100, after: null) {
edges {
cursor
}
nodes {
content {
... on Issue {
title
assignees(first: 1) {
nodes {
login
}
}
milestone {
title
}
labels(first: 5) {
nodes {
name
}
}
repository{
name
}
}
}
fieldValues(first: 15) {
nodes {
value
projectField {
name
settings
}
}
}
}
}
}
}
}
Those codes can be easily tested in THIS LINK

Github list of tag and release asset urls

I'm struggling with the github graphql interface to get the data that I need. I want to get a list of asset urls for both tags and releases. It seems that some repos produce my desired result while others produce nothing.
query {
repository(owner:"erlang",name:"otp") {
releases(last:100) {
edges {
node {
url
releaseAssets(last:100) {
edges {
node {
downloadUrl
}
}
}
tag {
name
target {
... on Commit {
zipballUrl
tarballUrl
}
}
}
}
}
}
tags:refs(refPrefix:"refs/tags/", last:30) {
edges {
tag:node {
name
target {
sha:oid
commitResourcePath
... on Commit {
zipballUrl
tarballUrl
author {
name
email
date
}
}
}
}
}
}
}
}
That query, as is, produces my desired results(or at least some them) whereas owner:"spring-projects",name:"spring-framework" produces tags with no tarball. When I look at the spring-framework repo it obviously has assets for releases.
Why are they not showing in this query? When I look at git every release and tag has assets yet, even in my query, the results are hit or miss. What am I missing?
target is a git reference, in that case it can point to a Tag or a Commit object. When it points to a Commit, your query returns the expected result since ...on Commit is not empty. To get the Tag as well just try out with ...on Tag and extract the tagger or the commit it points to depending on what you want. Here is an example :
{
repository(owner: "spring-projects", name: "spring-framework") {
releases(last: 100) {
edges {
node {
url
releaseAssets(last: 100) {
edges {
node {
downloadUrl
}
}
}
tag {
...refInfo
}
}
}
}
tags: refs(refPrefix: "refs/tags/", last: 30) {
edges {
node {
...refInfo
}
}
}
}
}
fragment refInfo on Ref {
name
target {
sha: oid
commitResourcePath
__typename
... on Tag {
target {
... on Commit {
...commitInfo
}
}
tagger {
name
email
date
}
}
... on Commit {
...commitInfo
}
}
}
fragment commitInfo on Commit {
zipballUrl
tarballUrl
author {
name
email
date
}
}
Try it in the explorer
Note that in the example above, I've used fragments to reduce the query size & improve readibility
My guess is that in case the ref is pointing to a Tag object that's an annotated tag which can hold a message, a specific tagging date & tagger info. If it points to a Commit object, it's a lightweight tag which is just linking to a commit

Grails URL id field not getting mapped to params

Here is my URLmappings.groovy
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.${format})?" {
constraints {
// apply constraints here
}
}
"/ewhet/$id"(controller : "ewhet", action : "show")
"/"(view: "/index")
"500"(view: '/error')
}
}
Here is my ewhetController's show action:
class EwhetController {
def index(){
}
def show(){
def ctx = startAsync()
ctx.start {
render params
//render "this invoked!!"
ctx.complete()
}
}
}
Now when I enter the url as: http://localhost:8080/g24/ewhet/abc
The abc does not get mapped to the params.id and when I render params, I get an empty map [:] . In case if url is entered as http://localhost:8080/g24/ewhet/show?id=abc the id field gets mapped to the params.id and I get:
['id':'abc']
So I just want to get the last part of the url mapped to the id parameter in params map without using any map in the url (like id=abc) as per Section 7.4.3 in Grails documentation So how is that possible and why is my approach not working?
Kindly note that I do not have any domain classes as I am using schemaless mongodb at my backend.
Try to reload the app after changing the UrlMappings.groovy to assure the new config is correctly loaded.

BlackBerry 10 Cascades: How to invoke Contacts with prefilled fields?

As the title says, I'm trying to invoke Contacts in BlackBerry Cascades:
https://developer.blackberry.com/cascades/documentation/device_platform/invocation/contacts.html
with fields filled from string variable containing a vCard. I have had no success with mimeTypes, URIs, actions and targets specified in above documentation. The following code or any variation I could develop from documented cases doesn't invoke:
Container {
property string inputString //contains data from which vCard should be extracted if detected
//....
attachedObjects: [
Invocation {
id: myQuery
property bool ready: false
query {
mimeType: "text/plain"
invokeTargetId: "sys.browser"
uri: ("http://www.google.com/search?q="+ escape(inputString))
invokeActionId: "bb.action.OPEN"
data: ""
onArmed: {myQuery.ready = true}
onQueryChanged: {
myQuery.query.updateQuery()
}
}
}
//....
if (inputString.indexOf("VCARD") > -1) {
myInvocation.query.setMimeType("");
myInvocation.query.setUri(inputString);
myInvocation.query.setData(inputString);
myInvocation.query.setInvokeTargetId("sys.pim.contacts.card.viewer");
myInvocation.query.setInvokeActionId("bb.action.VIEW");
myInvocation.query.updateQuery();
}
//...
Button {
onClicked: {
if (myQuery.ready = true) {
myQuery.trigger(myQuery.query.invokeActionId);
}
}
}
}
Other invocations like SMS, eMail & Browser do invoke with this setup, although the MimeType, URIs, data, targets and actions took some fiddling to set right and the configuration that finally worked is not the one from the documentation.
So, how to invoke Contacts?
I've modified your code so now you'll be able to launch as the browser app (as in the code you provided) as the contact app. I don't have any contact set up on my dev device, so in order to view a certain contact you need to provide respective contact ID (see ContactService for information on this) and so on
import bb.cascades 1.0
Page {
Container {
property string inputString //contains data from which vCard should be extracted if detected
//....
Button {
text: "..."
onClicked: {
myQuery.trigger(myQuery.query.invokeActionId); // launches browser
contactInvocation.trigger(contactInvocation.query.invokeActionId); // launches contacts
}
}
attachedObjects: [
Invocation {
id: myQuery
query {
mimeType: "text/plain"
invokeTargetId: "sys.browser"
uri: ("http://www.google.com/search?q=" + escape("sample"))
invokeActionId: "bb.action.OPEN"
onQueryChanged: {
myQuery.query.updateQuery()
}
}
},
Invocation {
id: contactInvocation
query {
invokeTargetId: "sys.pim.contacts.app"
mimeType: "application/vnd.blackberry.contact.id"
invokeActionId: "bb.action.OPEN"
onQueryChanged: {
contactInvocation.query.updateQuery()
}
}
}
]
}
}

SharePoint 2010 Document library versions comment

I would like to force users to add their comments before checking-in document.
When a user selects Check-in, the default popup page will show in order to select version and write comments, but comments field is not mandatory, can we make it as a required field??
You could do it via EventReceiver:
public class EventReceiver1 : SPItemEventReceiver
{
public override void ItemCheckingIn(SPItemEventProperties properties)
{
base.ItemCheckingIn(properties);
string comment = (string)properties.AfterProperties["vti_sourcecontrolcheckincomment"];
if (string.IsNullOrEmpty(comment))
{
properties.ErrorMessage = "Comment empty";
properties.Cancel = true;
}
}
}