Created
July 30, 2016 00:34
-
-
Save fforres/760184ae240746d6c357aa59f14edd63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function getCoworkByName(name) { | |
try { | |
const coworkByName = await getCoworkByNameAsync(name); //Devuelve el objeto del siguiente file | |
console.log(coworkByName); | |
return coworkByName; | |
} catch (err) { | |
console.log(err); | |
return err; | |
} | |
} | |
export async function getCoworks() { | |
try { | |
const coworksList = await getCoworksAsync(); //Devuelve el array de objetos del siguiente file | |
return coworksList; | |
} catch (err) { | |
return err; | |
} | |
} | |
export const coworkType = new GraphQLObjectType({ | |
name: 'Cowork', | |
fields: { | |
name: { | |
type: GraphQLString, | |
description: 'Cowork Display Name', | |
}, | |
id: { | |
type: GraphQLInt, | |
description: 'Unique Cowork ID', | |
}, | |
phoneNumber: { | |
type: GraphQLString, | |
description: 'Contact telepone number for the cowork', | |
}, | |
latitud: { | |
type: GraphQLFloat, | |
description: 'latitud for the Cowork', | |
}, | |
longitud: { | |
type: GraphQLFloat, | |
description: 'longitud for the Cowork', | |
}, | |
webpage: { | |
type: GraphQLString, | |
description: 'the webpage for the cowork', | |
}, | |
}, | |
}); | |
export const coworksListType = new GraphQLObjectType({ | |
name: 'CoworksList', | |
fields: { | |
coworks: { | |
type: new GraphQLList(coworkType), | |
description: 'List of coworks', | |
}, | |
}, | |
}); | |
export const coworkByName = { | |
type: coworkType, | |
args: { | |
name: { | |
type: new GraphQLNonNull(GraphQLString), | |
description: 'Cowork Display Name', | |
}, | |
}, | |
resolve: (root, { name }) => getCoworkByName(name), | |
}; | |
export const coworkList = { | |
type: coworksListType, | |
resolve: () => getCoworks(), | |
}; | |
const schema = new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'Query', | |
fields: { | |
coworkList, | |
coworkByName, | |
}, | |
}), | |
}); | |
export default schema; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
name: 'Co-Work - Santiago Centro', | |
id: 3636, | |
country: 'CL', | |
city: 'santiago', | |
number: '863', | |
phoneNumber: '+56985135860', | |
latitud: -33.4394101, | |
longitud: -70.649078, | |
webpage: 'http://www.coworklatam.com/' | |
}, { | |
name: 'La Ofi', | |
id: 3637, | |
country: 'CL', | |
city: 'santiago', | |
number: '140', | |
phoneNumber: '+56229854768', | |
latitud: -33.441609, | |
longitud: -70.6297092, | |
webpage: 'http://www.coworkinglaofi.cl/' | |
} | |
] | |
{ | |
name: 'La Ofi', | |
id: 3637, | |
country: 'CL', | |
city: 'santiago', | |
number: '140', | |
phoneNumber: '+56229854768', | |
latitud: -33.441609, | |
longitud: -70.6297092, | |
webpage: 'http://www.coworkinglaofi.cl/' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment